Finding user's home dir

Peter Hansen peter at engcorp.com
Thu Feb 3 09:43:31 EST 2005


Bernhard Herzog wrote:
> Peter Hansen <peter at engcorp.com> writes:
>>Miki Tebeka wrote:
>>
>>>>Hi all, I'm trying to write a multiplatform function that tries to
>>>>return the actual user home directory.
>>>>...
>>>
>>>What's wrong with:
>>>    from user import home
>>>which does about what your code does.
>>
>>:-)
>>
>>I suspect he simply didn't know about it.  I didn't either...
> 
> The purpose of the user module is executing ~/.pythonrc.py, which may
> not desirable.  It definitely shouldn't be done by a library, for
> instance.  Also, that the user's home directory is available as
> user.home is not documented, and I for one wouldn't want to rely on
> that.

Then please interpret my "please use the above recipe"
as suggesting he should do what the equivalent code in
the user.py module does in terms of finding the "home folder"
of the user, rather than his own home-grown approach.

-Peter



More information about the Python-list mailing list