Global Configuration Variables
Aahz Maruch
aahz at panix.com
Tue Oct 17 13:05:14 EDT 2000
In article <slrn8unup8.k2.mballen at angus.mimosa.com>,
Michael B. Allen <mballen at erols.com> wrote:
>
>I would like to have some global configuration parameters in a class
>that can be accessed like this:
>
>server = smtplib.SMTP(Config.mailserver)
>...
>
>My class might have default values, be stored in a module called
>config.py, and look like this:
>
>class Config:
> spoolfile = 'mail.spool'
> mailserver = os.environ['HOSTNAME']
> mailaddr = os.environ['USER'] + '@' + mailserver
> ...
>
>and then I want to be able to override these defaults with something like:
>
>def configinit(filename):
> execfile(filename, Config.__dict__)
The only change I'd recommend is making configinit a method of Config
rather than a separate function.
--
--- Aahz (Copyright 2000 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
"You have fundamentally misunderstood Usenet. Please go read the articles
posted to news.announce.newusers, particularly those which clearly explain
that Usenet is not a right, that Usenet is not a government, and that
Usenet is not a democracy. Hope this helps." -- rra
More information about the Python-list
mailing list