[Pythonmac-SIG] Temp files/dir

bill fancher bfancher@mac.com
Fri, 13 Sep 2002 12:20:53 -0700


On Friday, September 13, 2002, at 10:54 AM, Robin Siebler wrote:

> I guess I didn't word this very well.  What I was trying to find out 
> was *where* to place temp files, which is very easy to find out in 
> Windows.  After pounding my head against the monitor and searching 
> Google for about 30 minutes, I finally found this AppleScript command 
> "path to temporary items folder", which seems to be what I wanted to 
> know.  Thanks for the help though.  Aside from a post to this group, I 
> never found anything that said how to find the startup disk on a Mac.

Following the pointer Dinu helpfully provided...

 >>> import tempfile
 >>> tempfile.mktemp()
'MacOSX:private:tmp:502:Temporary Items:Python-Tmp-0'
 >>>

Or in "MachoPython"

 >>> import tempfile
 >>> tempfile.mktemp()
'/tmp/tmpxH2Fb4'
 >>>

I've never used this before. It took about two minutes to figure out. 
Further, tempfile provides cross-platform support for creating temp 
files, so you really don't need to know the folder name on ANY platform.

Pointing out how much "better" Windows is probably won't win you many 
friends on this list.

--
bill