small question

Rene Pijlman reply.in at the.newsgroup
Sun Mar 16 08:56:42 EST 2003


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])

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.

-- 
René Pijlman




More information about the Python-list mailing list