Store multiple dictionaries in a file

bruno modulix onurb at xiludom.gro
Thu Jun 30 06:43:24 EDT 2005


Philipp H. Mohr wrote:
> Hello,
> 
> I would like to store multiple dictionaries in a file, if possible one per
> line. 

Why "one per line" ?

> My code currently produces a new dictionary every iteration and
> passes it on to another peace of code. 

May this code rest in piece <grin>

> In order to be able to re-run some
> experiments at a later date I would like to store every dictionary in the
> same file.
> I looked at pickel, but that seems to require a whole file for each
> dictionary.
> 
> It would be great if some one could tell me how to do that.

A pretty simple solution could be to store all the dicts in another
container (list or dict, depending on how you need to retrieve'em, but
from what you explain I'd say a list) and then pickle this container.

My 2 cents...
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list