Finding startup files

Grant Edwards grante at visi.com
Wed May 11 12:42:18 EDT 2005


On 2005-05-11, jeff elkins <jeffelkins at earthlink.net> wrote:

> I'm creating an app that relies on a configuration file at
> launch. The file will always exist in the app's installation
> directory,

That's the first decision you need to examine.  If you want
work on Unix platforms, that's not where configuration files go.
If you're talking about Windows, then all bets are off and you
can ignore the rest of this post.

> but I have no control over where that might be. 

Exactly.

> Is there an OS-independent way that I can instruct the app to
> look in it's home directory for startup files?

No.  That's not even the right place to look under Unix.  If
you want to do things the "right" way under Unix, you look in
places like

 /etc/<appname>
 /etc/<appname>/whatever
 /usr/local/etc/<appname>
 /usr/local/etc/<appname>/whatever

One of the above would be used for system-wide configuration
stuff.

 $HOME/.<appname>rc
 $HOME/.<appname>/whatever

One of the above would be used for user-specific configuration
 
> Right now, I'm hard coding the path, which won't work. 

-- 
Grant Edwards                   grante             Yow!  I am covered with
                                  at               pure vegetable oil and I am
                               visi.com            writing a best seller!



More information about the Python-list mailing list