Re: Array of objects lost in unpickling

2009-09-13 Thread Bahadir
On Sep 13, 5:48 pm, Jon Clements wrote: > On 13 Sep, 15:19, Bahadir wrote: > > > > > Hi, > > > I have a class: > > > class second: > >     a = None > >     b = None > > > class first: > >     array = [] > > > I populate the array in first class with instances of second, then > > save by: > > > sh

Re: Array of objects lost in unpickling

2009-09-13 Thread Christian Heimes
Bahadir wrote: > Also there are no errors printed out. > > Any idea why the array of instances are lost? > The pickle protocol doesn't pickle class attributes by default, only instance variables. You list called 'array' is a class variable -- it's bound to the class not your instance. By the wa

Re: Array of objects lost in unpickling

2009-09-13 Thread Jon Clements
On 13 Sep, 15:19, Bahadir wrote: > Hi, > > I have a class: > > class second: >     a = None >     b = None > > class first: >     array = [] > > I populate the array in first class with instances of second, then > save by: > > shelve = shelve.open(), > shelve["first"] = myfirst > shelve.close() >

Array of objects lost in unpickling

2009-09-13 Thread Bahadir
Hi, I have a class: class second: a = None b = None class first: array = [] I populate the array in first class with instances of second, then save by: shelve = shelve.open(), shelve["first"] = myfirst shelve.close() When I reopen the shelve from another script, the first class is