"chicken and egg" problem with modules and global vars

Graham Guttocks graham_guttocks at yahoo.co.nz
Sun Apr 29 16:53:17 EDT 2001


Roman Suzi <rnd at onego.ru> wrote:

> 1- you can use getopt earlier: command line params usually have more
> priority than config-file ones.

OK, this is the simple thing to do, but is it the right thing?  I
don't want to be accused of bad program design.  Here is what I did:

I moved the getopt section out of main to the very top of the program;
after import of the standard modules, but before import of my
"Default" module and before my function declarations.  Now things
work, but somehow I'm uneasy about the way things look.

> 2- global vars are bad idea. You can use os.environ to put
> configuration (environment) parameters, such as config file, there.

Great suggestion, thanks.

Regards,
Graham

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/




More information about the Python-list mailing list