save configuration information in a global class
Steven Bethard
steven.bethard at gmail.com
Mon Mar 28 01:53:05 EST 2005
Su Wei <pollux.suwei at gmail.com> wrote:
> if i want to make a global class to save configuration information of
> app that is read from a xml file,what can i do?
Just put it in a module. Say, 'progconfig.py'. Your configuration
code can then look like:
import progconfig
# parse configuration information from an XML file
for name, value in configuration_information:
setattr(progconfig, name, value)
Now all you have to do to use this information is to import the same
module in your other modules, e.g.:
import progconfig
# do whatever you normally do in this module, e.g.
if progconfig.sayhello:
print "say hello"
STeVe
--
You can wordify anything if you just verb it.
--- Bucky Katt, Get Fuzzy
More information about the Python-list
mailing list