[Tutor] Writing a Configuration Facility for an Application

Willi Richert w.richert at gmx.net
Fri Jan 30 14:17:34 CET 2009


I have often found that just initializing all the necessary stuff in one 
Configuration.py module. You just import it and it works.

If you like the Windows .ini format, ConfigParser is your friend 


On Freitag, 30. Januar 2009 13:53:08 Kent Johnson wrote:
> On Fri, Jan 30, 2009 at 7:40 AM, Wayne Watson
> <sierra_mtnview at sbcglobal.net> wrote:
> > I'm about to provide a config file for an application I've been working
> > with.
> >
> > I suspect there may be a standard way of doing this in Python that relies
> > on more complex operations that simplify matters than just reading the
> > file one line at a time. Dictionaries?  Comments?
> One possibility is to put the settings in a dictionary and use the
> pickle module to save and restore the dict. This is pretty simple. The
> pickled file is not particularly readable, though.
> http://docs.python.org/library/pickle.html
> Another way is to use a .ini file. The ConfigParser module can read
> ini files but not write them.
> http://docs.python.org/library/configparser.html
> There are add-on modules that implement read-write ini files, for example
> http://www.voidspace.org.uk/python/configobj.html
> Kent
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090130/ed58c8dd/attachment.htm>

More information about the Tutor mailing list