[Tutor] tempfile and webbrowser

yves yegrix at free.fr
Thu Sep 7 22:16:44 CEST 2006


Hello,

Here is another problem:
Considering this programm:
########
import os, tempfile

a = tempfile.mkstemp()
f= open(a[1],'w')
f.write("foo")
f.close()
print f.name
# here some code to do some things with f
os.unlink(f.name)
####################
The output is:
Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.

 >>> ## working on region in file

c:/DOCUME~1/Yves/LOCALS~1/Temp/python-1408y8u...
c:\docume~1\yves\locals~1\temp\tmp8fr4-9
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "c:/DOCUME~1/Yves/LOCALS~1/Temp/python-1408y8u", line 8, in ?
     os.unlink(f.name)
OSError: [Errno 13] Permission denied:
'c:\\docume~1\\yves\\locals~1\\temp\\tmp8fr4-9'

 >>>

The file deletion (os.unlink(f.name)) does not work on Windows (it works 
  on Ubuntu with Python 2.4, though).

So, is there a way to get this os.unlink(f.name) to work on Windows?

-- 
Yves Egrix



More information about the Tutor mailing list