By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,275 Members | 1,745 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,275 IT Pros & Developers. It's quick & easy.

Finding a script's home directory?

P: n/a
In one of my python programs has a data file I need to load. My solution
was to say:

if os.path.exists(os.path.join(os.getcwd(), "config.xml")):
self.cfgfile = os.path.join(os.getcwd(), "config.xml")

Which works fine... as long as you're *in* the script's home directory
when you run it (as in, run it as: ./startApp.py as opposed to
../myApp/startApp.py).

If I run it from an alternate directory the program looks for the
config.xml file in my current directory not the app's home directory. So
how do I get the script's home directory?
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.