Get Path of current Script

2011-03-14 Thread Alexander Schatten
Hi,

could someone help me with a small problem? I wrote a Python script
that does some RegEx... transformations. Now, this script loads some
configuration data from a file located in the same directory:

open ('config.txt', 'r').

However, this only works when I execute the script being in the
directory where the script is locates, because otherwise, of course,
this config file is not found, as the path is relative. Now my
question: is there an easy way (API) to get the directory of the
currently running script? Something along the line of:

open (API.getCurrentPath + 'config.txt', 'r').


thanks a lot,

cheers

Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get Path of current Script

2011-03-14 Thread Alexander Schatten
Thanks for the comments so far. This sounds to be more complicated in
detail than I expected. I wonder how all the other Python programs and
scripts are doing that...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get Path of current Script

2011-03-14 Thread Alexander Schatten
They don't. Hm, ok, I am always for best practices. If there is a
better way to do it I am open for suggestions ;-) How would the best
practice be to load configuration data from a file.

I mean, this is something very common: you write a program or a script
and want to load some configuration data.


thanks


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list