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

learner404 learner404 at gmail.com
Wed Apr 19 19:55:14 CEST 2006


Hello,

I want to read a configuration file from a small python app (user
preferences).

The ".myapp.conf" is in the home folder of the user.

if I do:

f=open("/home/user1/.myapp.conf","r")  #it works

obviously I won't know the home user folder name then I wanted to use:

f=open("~/.myapp.conf","r")  # but it returns a IOError: [Errno 2] No such
file or directory:

How can I do to access this file whatever the user is ?

Thanks for your help.

---
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060419/cd2d8a1f/attachment.htm 


More information about the Tutor mailing list