|
From: Michael F. <fuz...@vo...> - 2009-04-14 09:42:21
|
Ramon Felciano wrote:
> Hi --
>
> I'm trying to migrate a bunch of hard-coded configuration information
> to an external INI file with ConfigObj. I am using this in a Python
> package that has a bunch of individual files, typically called from
> the command line, as well as library or utility scripts that are
> called from the command-line files. I'd like any of these to have
> access to a shared, parsed configuration object, but I'm not actually
> sure how to implement that elegantly. I would imagine this is common
> for ConfigObj users that just want config info loaded once per
> invocation. Is there a pythonic way of handling singleton patterns
> like this? Should I stick the ConfigObj loader in a separate config.py
> file that is loaded from each other script?
Having a single module ('config.py' or whatever) responsible for
retrieving configuration information is a pattern I have seen used
several times before. Modules are effectively singletons in Python so it
is an effective way of dividing responsibilities.
Michael
>
> Thanks!
>
> Ramon
>
> P.S. I'm not actually sure I need a singleton in the OO sense: the
> configuration info doesn't need to be wrapped in a class instance, but
> just needs a simple way to access the loaded configuration object.
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> ------------------------------------------------------------------------
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
|