Style: global configuration data
Boudewijn Rempt
boud at rempt.xs4all.nl
Mon Nov 13 06:54:32 EST 2000
Michael Hudson <mwh21 at cam.ac.uk> wrote:
> boud at rempt.xs4all.nl (Boudewijn Rempt) writes:
>> I have been wondering for some time about the best way to offer
>> configuration data and other global resources to all modules and classes
>> in my application, other than creating a config object and passing that
>> on with every constructor. What's the received Pythonic wisdom on this?
>>
>> I'd prefer to just have one instance of my config class, or my repository
>> class or whatever, so if I were working in Java I'd create a singleton, but
>> that somehow doesn't seem right for Python to me.
> Having a module "config"? Modules are handy in the way that if two
> modules both go
> import config
> they get the same module.
> If config.py you could read the config from a ~/.rc file, the
> registry, star patterns, whatever. I can think of situations where
> this might not work, but it has the benfit of being simple...
I wonder - does that also work when one of the client modules changes
a setting in the config? Are the other modules then updated?
--
Boudewijn Rempt | http://www.valdyas.org
More information about the Python-list
mailing list