[Tutor] [Linux] open a file in any home "~" ?

Alan Gauld alan.gauld at freenet.co.uk
Wed Apr 19 21:29:36 CEST 2006

> The ".myapp.conf" is in the home folder of the user.
> ...
> obviously I won't know the home user folder name then I wanted to use:
> How can I do to access this file whatever the user is ?

You can get the user name using getpass.getuser() as described in 
the OS topic of my tutor under the Securiity heading.

You can also try using os.getenv() or the os.environ variable 
to look up the HOME environment variable, also discussed 
in the OS topic.


Alan G
Author of the learn to program web tutor

More information about the Tutor mailing list