Can anyone elaborate on how 'os.tmpfile()' works? I was thinking it would create some sort of temporary file I could quickly add text too and then when I was finished would automatically get rid of it. Here's my questions:
1. Does it actually create a file somewhere? If so, where does it store it? Does it have to manually be deleted afterwards? 3. How do you use it? I tried the following, but it doesn't seem to work: >>> import os >>> c = os.tmpfile() >>> c.write('dude') >>> c.read() '' >>> os.path.exists(c) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/posixpath.py", line 171, in exists TypeError: coercing to Unicode: need string or buffer, file found >>> type(c) <type 'file'> >>> os.path.basename(c) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/posixpath.py", line 112, in basename File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/posixpath.py", line 77, in split AttributeError: 'file' object has no attribute 'rfind' >>> for x in c: ... print x ... >>> Can you actually 'write' to this file? And if so, do you have to 'close()' it when you're done with it? Thanks for your help with this... I'm still learning Python and haven't been able to find out much about this in the documentation or on-line. Jay -- http://mail.python.org/mailman/listinfo/python-list