cPickle and subclassing lists?

Reckoner reckoner at gmail.com
Fri Apr 17 16:58:28 EDT 2009


On Apr 17, 11:16 am, Piet van Oostrum <p... at cs.uu.nl> wrote:
> >>>>> Reckoner <recko... at gmail.com> (R) wrote:
> >R> I have a large class that is a child of list. I need to pickle it, but
> >R> it's not working. For example, I have reduced it to the following:
> >R> class Mylist(list):
> >R>     def __init__(self,x=[]):
> >R>       list.__init__(self,x)
> >R> and I cannot even get this to pickle right.
> >>>> w=Mylist([1,2,3])
> >>>> dumps(w)
> >R> PicklingError: Can't pickle <class '__main__.p'>: attribute lookup
> >R> __main__.p fa
> >R> iled
>
> Where does the 'p' come from?
> What is w.__class__ ?
>
> >R> I'm using python 2.5 on win32.
>
> No problem with 2.6.2 on Mac OS X.
> --
> Piet van Oostrum <p... at cs.uu.nl>
> URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
> Private email: p... at vanoostrum.org

Thanks for all the great feedback. This turns out to be a problem with
the IPython interpreter,
and not a Python problem.

sorry for the confusion.





More information about the Python-list mailing list