os independent temp dir?
m.hadfield at niwa.cri.nz
Thu May 10 00:29:55 CEST 2001
Responding to a couple of different posts in this thread:
> On the Mac it appears you should store files in the "Temporary Items"
> folder of the boot volume (don't ask me how you find the boot volume).
Luckily, one of the contributors to the tempfile module did know that,
witness the following code snippet.
elif os.name == 'mac':
import macfs, MACFS
refnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk,
dirname = macfs.FSSpec((refnum, dirid, '')).as_pathname()
Read the source, Luke!
When you do you will also see
if os.name == 'nt':
for envname in 'TMPDIR', 'TEMP', 'TMP':
(Question, what is os.name on Windows 95/98/ME? I think it's 'nt'.)
So tempfile makes a pretty thorough attempt to find an os-independent
tempdir, and if you have a system on which it doesn't work, you should
1. Consider the possibility that your system may be mis-configured
2. Propose a patch to tempfile that covers your case, preferably without
further cluttering up the code any more.
It is my experience that the Windows installer normally sets up a TEMP
directory under the Windows directory, and a TEMP environment variable
pointing to it, so any system lacking one can be considered mis-configured.
But perhaps this is not true of 98 and/or ME.
m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research
Posted from clam.niwa.cri.nz [18.104.22.168]
via Mailgate.ORG Server - http://www.Mailgate.ORG
More information about the Python-list