[Tutor] save configuration of one application.

John Fouhy john at fouhy.net
Wed Oct 4 06:54:07 CEST 2006


On 04/10/06, Luke Paireepinart <rabidpoobear at gmail.com> wrote:
> you can make a config.ini file and use that one module that parses ini
> files.
> I can't remember what it's called.
> configparser I think, but I wouldn't bet my life on it :)

Yes, ConfigParser.

The docs for ConfigParser are a bit confusing in places (IMO), but
there are people here who can help if you get stuck.

> Or you could just write the settings out to a file.

Using ConfigParser means your configuratino files will be
human-readable and human-editable.  If you don't care about that, you
could stick them in a dictionary and use pickle to write it to a file.
 Or use the shelve module.

> If you choose to go the latter route, keep in mind that  modules are
> compiled to .pyc files upon importation,
> so you'll have to remove those anytime you modify config.py or the old
> code will be used instead.

The python interpreter should check the timestamps on foo.py vs
foo.pyc, and recompile if it thinks things have changed.

-- 
John.


More information about the Tutor mailing list