help with using temporary files

Gerard Flanagan grflanagan at yahoo.co.uk
Tue Nov 22 11:03:37 EST 2005


Hello

 I'm sure its basic but I'm confused about the error I get with the
following code.  Any help on basic tempfile usage?


ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on
Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from tempfile import NamedTemporaryFile
>>>
>>> tmp = NamedTemporaryFile()
>>> tmp.write("Hello")
>>> tmp.close()
>>>
>>> print tmp.name
c:\docume~1\gerard\locals~1\temp\tmpxqn4yl
>>>
>>> f = open(tmp.name)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory:
'c:\\docume~1\\gerard\\locals~1\\temp\\tmpxqn4yl'


Thanks

Gerard




More information about the Python-list mailing list