NamedTemporaryFile does not match documentation

Jason Friedman jsf80238 at
Fri Feb 22 03:10:40 CET 2013

> 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

More information about the Python-list mailing list