Movatterモバイル変換


[0]ホーム

URL:


"chicken and egg" problem with modules and global vars

Graham Guttocksgraham_guttocks at yahoo.co.nz
Sun Apr 29 15:27:30 EDT 2001


Greetings,I'm running into a sort of "chicken and egg" problem involvingmodules, global variables and getopt command-line arguments and wouldappreciate some direction.I'm importing a module named "Defaults" at the top of my program whichdefines a number of default values as well as parses a userconfiguration file for more default values.  These values are used inthe program's function definitions including main().I need the ability for the user to override the default location ofhis custom config-file which is defined in "Defaults".  I'm doing thiswith getopt in main() by appending to __builtin__ so that "Defaults"can access it.The problem is that since "Defaults" is imported at the top of theprogram, the default config-file location is set as soon as thismodule is imported.  I need getopt to be read first, but I can't justmove "import Defaults" down into the body of main() because thefunction definitions above main() rely on it.Any ideas?Regards,Graham__________________________________________________Do You Yahoo!?Yahoo! Auctions - buy the things you want at great priceshttp://auctions.yahoo.com/


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp