You can make it a required input with default values to sys.argv when you
start the program. Parse the content of the file given by sys.argv, then
cache it in some global module or pass it around as arguments...

That said, if you still want to go the route of knowing where the current
directory of a given script is, I would do:

import os

HERE = os.path.dirname(os.path.abspath(__file__))
CFGFILE = os.path.join(HERE, 'config.cfg')

~/santa


On Mon, Mar 14, 2011 at 11:25 AM, Alexander Schatten <asch...@gmail.com>wrote:

> 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
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to