Author Howard Waterfall
Recipients Howard Waterfall, docs@python
Date 2020-04-05.00:39:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1586047164.62.0.92715958345.issue40191@roundup.psfhosted.org>
In-reply-to
Content
The documentation for tempfile.mkstemp() says:
returns a tuple containing an OS-level handle to an open file (as would be returned by os.open()) and the absolute pathname of that file, in that order.

I don't believe this is correct. It should say:
returns a tuple containing an OS-level file descriptor and the absolute pathname of that file, in that order.

I say this because this works:
    file_descriptor, uri = tempfile.mkstemp()
    open_file = os.fdopen(file_descriptor, 'w')
    open_file.write("hello world")
    print(uri)

but this raises an error:
    open_file, uri = tempfile.mkstemp()
    open_file.write("hello world")
    print(uri)

    Traceback (most recent call last):
    File "test.py", line 78, in <module>
        main()
    File "test.py", line 74, in main
        open_file.write("hello world")
    AttributeError: 'int' object has no attribute 'write'
History
Date User Action Args
2020-04-05 00:39:24Howard Waterfallsetrecipients: + Howard Waterfall, docs@python
2020-04-05 00:39:24Howard Waterfallsetmessageid: <1586047164.62.0.92715958345.issue40191@roundup.psfhosted.org>
2020-04-05 00:39:24Howard Waterfalllinkissue40191 messages
2020-04-05 00:39:23Howard Waterfallcreate