"chicken and egg" problem with modules and global vars

Roman Suzi rnd at onego.ru
Sun Apr 29 16:01:14 EDT 2001


On Sun, 29 Apr 2001, Graham Guttocks wrote:

>Greetings,
>
>I'm running into a sort of "chicken and egg" problem involving
>modules, global variables and getopt command-line arguments and would
>appreciate some direction.

>Any ideas?

1- you can use getopt earlier: command line params usually have
more priority than config-file ones.
2- global vars are bad idea. You can use os.environ to put
configuration (environment) parameters, such as config file, there.
This way globalisms will belong to the environment, not your program ;-)
(its half-joke)

*

I remember one of my programs where I had similar problem:
config file was written relative to argv[0].
So, I needed to determine it first. Thus I conclude you
need to get commandline options before any other config-specific
things. What if they contain only --help ;-)

>Regards,
>Graham
>

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Sunday, April 29, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Macho does not prove Mucho." _/






More information about the Python-list mailing list