Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39513
| References | <CANy1k1g4eJ+9aBArQm_r8k0iKKuaxf_wzKjdEjOkj7M0J7=N8A@mail.gmail.com> <kg63kp$742$1@ger.gmane.org> |
|---|---|
| Date | 2013-02-21 18:10 -0800 |
| Subject | Re: NamedTemporaryFile does not match documentation |
| From | Jason Friedman <jsf80238@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2232.1361499042.2939.python-list@python.org> (permalink) |
> 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
http://docs.python.org/release/3.2.2/library/tempfile.html#module-tempfile.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: NamedTemporaryFile does not match documentation Jason Friedman <jsf80238@gmail.com> - 2013-02-21 18:10 -0800
csiph-web