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”)