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

w chun wescpy at gmail.com
Wed Apr 19 20:24:43 CEST 2006


>  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 ?

use os.path.expanduser(path)

http://www.python.org/doc/2.4.3/lib/module-os.path.html

hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list