Sal
Peter Hoffmann Director Data Engineering at Blue Yonder. Python Developer, Conference Speaker, Mountaineer

Python - How do I convert an OS-level handle to an open file to a file object?

This my Answer to the stackoverflow question: Python - How do I convert "an OS-level handle to an open file" to a file object?:

You can use

os.write(tup[0], "foo\n")

to write to the handle.

If you want to open the handle for writing you need to add the "w" mode

f = os.fdopen(tup[0], "w")
f.write("foo")