Newbie Alert: Help me store constants pythonically

Jorge Godoy godoy at ieee.org
Mon Nov 7 20:23:20 EST 2005


"Brendan" <spam4bsimons at yahoo.ca> writes:

> seems risky.  Also my config files have (a tiny bit of) nested
> structure, such as:
> 
> Model1(
>    numBumps = 1
>    sizeOfBumps = 2
>    transversePlanes = [
>         Plane(type=3, z=4),
>         Plane(type=5, z=6),
>         Plane(type=3, z=8)
>     ]
> )
> 
> which I'm not sure the .ini format can easily support.  I could use
> (key buzzword voice) XML, but  I fear that might send me down the
> 'overcomplicating things' path.  Your suggestion has given me some new
> places to search Google (configparser, python config files), so I'll
> look around for better ideas.

Take a look at pickle (specially cPickle) module for pickling and unpickling
data directly from / to Python types.  What you want can be mapped to
dictionaries of lists of dictionaries. :-)

-- 
Jorge Godoy      <godoy at ieee.org>



More information about the Python-list mailing list