cPickle and subclassing lists?
Piet van Oostrum
piet at cs.uu.nl
Fri Apr 17 14:16:59 EDT 2009
>>>>> Reckoner <reckoner 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 <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list
mailing list