Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Temp dir creation

0 views
Skip to first unread message

marco

unread,
Mar 23, 2005, 10:10:43 PM3/23/05
to

I'm a bit puzzled by the following behaviour
(at least in the way I read
http://docs.python.org/lib/module-tempfile.html )

> python
Python 2.4 (#1, Mar 21 2005, 23:04:52)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> tfile = tempfile.mkstemp('','','.')
>>> tfile
(3, '/home/local/9qF7kf')

OK, it works as expected, but...

>>> tdir = tempfile.mkdtemp('','','.')
>>> tdir
'./HFXmX2'

I thought this should be '/home/local/HFXmX2'?
According to the doc page above "mkdtemp() returns
the absolute pathname of the new directory", which
isn't what I get:

>>> os.path.abspath(tdir)
'/home/local/HFXmX2'

Workaround I'm using:

>>> import os
>>> tdir = tempfile.mkdtemp('','',os.path.abspath('.'))
>>> tdir
'/home/local/5r8gFi'
>>>

Comments?

Cheers!

--
ma...@reimeika.ca
Gunnm: Broken Angel http://amv.reimeika.ca
http://reimeika.ca/ http://photo.reimeika.ca

0 new messages