Re: Store multiple dictionaries in a file

2005-06-30 Thread Philipp H. Mohr
Hello, this is the solution I went for, as I am indeed not concernt about security and the implementation is straight forward. Thank you, Phil > If you're not worried about security, you could write the repr() of each > dict to the file and get the values back by using the eval() function. > r

Re: Store multiple dictionaries in a file

2005-06-30 Thread Larry Bates
You might want to take a look at the shelve module. -Larry Philipp H. Mohr wrote: > Hello, > > I would like to store multiple dictionaries in a file, if possible one per > line. My code currently produces a new dictionary every iteration and > passes it on to another peace of code. In order to b

RE: Store multiple dictionaries in a file

2005-06-30 Thread Tim Golden
[John Machin] | | bruno modulix wrote: | > Philipp H. Mohr wrote: | | >>My code currently produces a new dictionary every iteration and | >>passes it on to another peace of code. | > | > | > May this code rest in piece | | Perhaps it's the piece of code that passeth all understanding? Th

Re: Store multiple dictionaries in a file

2005-06-30 Thread John Machin
bruno modulix wrote: > Philipp H. Mohr wrote: >>My code currently produces a new dictionary every iteration and >>passes it on to another peace of code. > > > May this code rest in piece Perhaps it's the piece of code that passeth all understanding? -- http://mail.python.org/mailman/listinfo

Re: Store multiple dictionaries in a file

2005-06-30 Thread Jeremy Sanders
Philipp H. Mohr wrote: > I would like to store multiple dictionaries in a file, if possible one per > line. My code currently produces a new dictionary every iteration and > passes it on to another peace of code. In order to be able to re-run some > experiments at a later date I would like to stor

Re: Store multiple dictionaries in a file

2005-06-30 Thread Philipp H. Mohr
Thank you for you answer. > > I would like to store multiple dictionaries in a file, if possible one per > > line. > > Why "one per line" ? I agree with you that it sounds like nasty code :-) but there is a good reason for doing it this way - I think. My code collects data (attributes) of its cu

Re: Store multiple dictionaries in a file

2005-06-30 Thread Andreas Kostyrka
How so? >>> import cPickle as cp >>> f=open("/tmp/test.pck", "wb") >>> cp.dump(dict(a=1), f) >>> cp.dump(dict(b=1), f) >>> f.close() >>> f=open("/tmp/test.pck", "rb") >>> cp.load(f) {'a': 1} >>> cp.load(f) {'b': 1} >>> cp.load(f) Traceback (most recent call last): File "", line 1, in ? EOFError

Re: Store multiple dictionaries in a file

2005-06-30 Thread bruno modulix
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 > In order to be