[Tutor] Writing a Configuration Facility for an Application

Kent Johnson kent37 at tds.net
Fri Jan 30 13:53:08 CET 2009

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.

Another way is to use a .ini file. The ConfigParser module can read
ini files but not write them.

There are add-on modules that implement read-write ini files, for example


More information about the Tutor mailing list