Automatically creating a HOME environ variable on Windows?
Micah Elliott
mde at micah.elliott.name
Tue Nov 1 11:37:34 EST 2005
Maciej Dziardziel wrote:
> > ...there is a group of path related functions in os.path (or
> > ntpath), including expanduser, and its better to use function...
On Nov 01, jim.eggleston at gmail.com wrote:
> Having a function is definitely cleaner. Creating a HOME environment
> variable where one does not exist in the calling shell is
> misleading.
> ...
> It would be nice to start of with having a standard way to find out
> what the home directory is.
I think that is what Maciej has already pointed out.
Just to clarify then:
os.path.expanduser('~') is the universal/portable means to find a
user's home directory, regardless of platform. So use of HOME or
USERPROFILE or whatever in scripts should be discouraged.
Someone please correct me if the above is wrong. I haven't tried on a
mac, but linux and windows seem to behave well; i.e., linux looks for
HOME, and windows appears to combine HOMEDRIVE and HOMEPATH if HOME is
not set. Details are in the 2.4.2 sources' "Python24/Lib/posixpath.py"
if you're curious.
--
_ _ ___
|V|icah |- lliott http://micah.elliott.name mde at micah.elliott.name
" " """
More information about the Python-list
mailing list