reading files into dicts

Fuzzyman fuzzyman at gmail.com
Fri Dec 30 03:40:21 EST 2005


ConfigObj is good - it (effectively) turns a dictionary into an ini
file, and vice versa.

There is also built in support for type conversion.

See http://www.voidspace.org.uk/python/configobj.html

See the ConfigPersist module which has functions to use ConfigObj for
data persistence. It explains the limitations.

http://www.voidspace.org.uk/python/configpersist.html

Basically you can store and retrieve dictionaries, lists, strings,
integers, floats and booleans. You can nest dictionaries - but you
can't nest dictionaries in lists. All the keys must be strings - but
the module/article suggests a way round that, at the expense of
readability of the resulting text file.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml




More information about the Python-list mailing list