Re: dump a multi dimensional dictionary

2013-07-26 Thread Steven D'Aprano
On Fri, 26 Jul 2013 13:21:47 -0700, cerr wrote: > or should I just write my own dump function that can hanle thiS? > > Please advise! Given the choice between reading the documentation to pickle.dump: help(pickle.dump) or spending the next month writing a replacement for pickle, testing it,

Re: dump a multi dimensional dictionary

2013-07-26 Thread Chris Angelico
On Fri, Jul 26, 2013 at 9:21 PM, cerr wrote: > >>> mylist = [] > >>> mydict = {} > >>> mylist = '1','2' Side point: mylist is no longer a list, it's a tuple. I don't think pickle has problems with tuples, but it's worth noting that difference. ChrisA -- http://mail.python.org/mailm

RE: dump a multi dimensional dictionary

2013-07-26 Thread Prasad, Ramit
cerr wrote: > Hi, > > Can I somehow use pickle.dump() to store a dictionary of lists to a file? > I tried this: > > >>> import pickle > >>> mylist = [] > >>> mydict = {} > >>> mylist = '1','2' > >>> mydict['3'] = mylist > >>> fhg = open ("test", 'w') > >>> pickle.dump(

Re: dump a multi dimensional dictionary

2013-07-26 Thread John Gordon
In cerr writes: > Can I somehow use pickle.dump() to store a dictionary of lists to a file? > I tried this: > >>> import pickle > >>> mylist = [] > >>> mydict = {} > >>> mylist = '1','2' > >>> mydict['3'] = mylist > >>> fhg = open ("test", 'w') > >>> pickle.dump(fhg

dump a multi dimensional dictionary

2013-07-26 Thread cerr
Hi, Can I somehow use pickle.dump() to store a dictionary of lists to a file? I tried this: >>> import pickle >>> mylist = [] >>> mydict = {} >>> mylist = '1','2' >>> mydict['3'] = mylist >>> fhg = open ("test", 'w') >>> pickle.dump(fhg,mydict) Traceback (most rece

Re: multi dimensional dictionary

2008-05-28 Thread Alok Kumar
Thanks to all for their kind help and time. Alok On Wed, May 28, 2008 at 4:11 AM, Peter Otten <[EMAIL PROTECTED]> wrote: > Gary Herron wrote: > > > Alok Kumar wrote: > >> Dear All, > >> > >> I am using dictionary for filling my xpath parsed data. > >> > >> I wanted to use in the following manner

Re: multi dimensional dictionary

2008-05-28 Thread Paul McGuire
On May 28, 3:11 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Gary Herron wrote: > > Alok Kumar wrote: > >> Dear All, > > >> I am using dictionary for filling my xpath parsed data. > > >> I wanted to use in the following manner. > > >> mydict[index] ["key1"] ["key2"]    #Can someone help me with rig

Re: multi dimensional dictionary

2008-05-28 Thread Peter Otten
Gary Herron wrote: > Alok Kumar wrote: >> Dear All, >> >> I am using dictionary for filling my xpath parsed data. >> >> I wanted to use in the following manner. >> >> mydict[index] ["key1"] ["key2"]#Can someone help me with right >> declaration. >> >> So that I can fill my XML xpath parsed dat

Re: multi dimensional dictionary

2008-05-28 Thread Hrvoje Niksic
Gary Herron <[EMAIL PROTECTED]> writes: > mydict[(0,"person","setTime")] = "12:09:30" > mydict[(0,"person","clrTime")] = "22:09:30" Note that this is more succinctly written as: mydict[0, "person", "setTime"] = "12:09:30" with the added advantage that it looks like a multi-dimensional array

Re: multi dimensional dictionary

2008-05-27 Thread Gary Herron
Alok Kumar wrote: Dear All, I am using dictionary for filling my xpath parsed data. I wanted to use in the following manner. mydict[index] ["key1"] ["key2"]#Can someone help me with right declaration. So that I can fill my XML xpath parsed data mydict[0] ["person"] ["setTime"] = "12:0

multi dimensional dictionary

2008-05-27 Thread Alok Kumar
Dear All, I am using dictionary for filling my xpath parsed data. I wanted to use in the following manner. mydict[index] ["key1"] ["key2"]#Can someone help me with right declaration. So that I can fill my XML xpath parsed data mydict[0] ["person"] ["setTime"] = "12:09:30" mydict[0] ["perso