NamedTemporaryFile does not match documentation

Chris Angelico rosuav at
Fri Feb 22 03:42:04 CET 2013

On Fri, Feb 22, 2013 at 1:10 PM, Jason Friedman <jsf80238 at> wrote:
>> NamedTemporaryFile by default opens a file in binary mode ('w+b'). Write
>> bytes or specify text mode.
>>>>> f.write(b"Hello World!\n")
>> 13
>>>>> ft = NamedTemporaryFile('w+', delete=False)
>>>>> ft.write("Hello World!\n")
>> 13
> Thank you Chris and Serhiy, that helped.  I'm inclined to open a
> documentation bug because I could not reproduce the code/output
> snippet on page

Yep, that looks like a docs bug (it was probably copied straight in
from the 2.x docs). Nice and easy to fix, you could submit a patch
with the bug report and make the devs love you!


More information about the Python-list mailing list