os independent temp dir?

Ben Hutchings ben.hutchings at roundpoint.com
Thu May 10 01:19:10 CEST 2001


"Mike C. Fletcher" <mcfletch at home.com> writes:

> How about:
> 
> >>> import os
> >>> def getTemp():
> ... 	for possible in ('temp','tmp','tmpdir'):
> ... 		if os.environ.has_key( possible):
> ... 			return os.environ[ possible ]
> ...
> >>> getTemp()
> 'c:\\temp'
> >>>
> 
> No idea if the Mac even has environmental variables, so no help there...
> It's a hack, but oh well :) .

Unix environmental variable names are case-sensitive and are
usually all-caps.

-- 
Any opinions expressed are my own and not necessarily those of Roundpoint.



More information about the Python-list mailing list