Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39456

NamedTemporaryFile does not match documentation

Date 2013-02-21 12:46 -0800
Subject NamedTemporaryFile does not match documentation
From Jason Friedman <jsf80238@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2194.1361479605.2939.python-list@python.org> (permalink)

Show all headers | View raw


Python 3.2.2 (default, Feb 14 2012, 08:06:31)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tempfile import NamedTemporaryFile
>>> f = NamedTemporaryFile(delete=False)
>>> f
<tempfile._TemporaryFileWrapper object at 0x7f867e8bc050>
>>> f.name
'/tmp/tmpqxnd_4'
>>> f.write("Hello World!\n")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface

Or, maybe I am reading the documentation incorrectly.  My goal is to
be able to write to that temporary file along the lines of "f.write()"
or "with open(f) as writer ...".

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

NamedTemporaryFile does not match documentation Jason Friedman <jsf80238@gmail.com> - 2013-02-21 12:46 -0800

csiph-web