small question

Ben Hutchings do-not-spam-ben.hutchings at
Tue Mar 18 18:16:22 CET 2003

In article <cf097vcss862rmi5n83gc0rp2dt1mhiea7 at>, Rene Pijlman wrote:
> Ian Bicking:
>>Ali Dada:
>>> how can i force a script to execute in the user's home directory?
>>If you want to go to a home directory of a user that's not the current
>>user, you can use the pwd module, like 
>>  os.chdir(pwd.getpwnam(username)[5])

Or, perhaps more readably:


> I think this is a better solution than os.environ['HOME'], even
> for the current user, since HOME is set to the user's home
> directory only by convention. It may be (re)set to anything in
> the execution environment of the script.

If the user shouldn't be allowed to change their home directory by
setting HOME, consider what they can do by setting PYTHONPATH...

More information about the Python-list mailing list