[IPython-user] cPickle works in standard interpreter, but not in IPython

Reckoner reckoner@gmail....
Fri Apr 17 13:09:07 CDT 2009


for example:

In IPython:


>> class Mylist(list):
        def __init__(self,x=[]):
            list.__init__(self,x)

>> from cPickle import dumps
>> w=Mylist([1,2,3])
>> dumps(w)

PicklingError: Can't pickle <class '__main__.Mylist'>: attribute
lookup __main__.Mylist failed

However, using the standard Python interpreter:

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from cPickle import dumps
>>> class Mylist(list):
...         def __init__(self,x=[]):
...             list.__init__(self,x)
...
>>> w=Mylist([1,2,3])
>>> dumps(w)
'ccopy_reg\n_reconstructor\np1\n(c__main__\nMylist\np2\nc__builtin__\nlist\np3\n
(lp4\nI1\naI2\naI3\natRp5\n.'
>>>



Why is this?

Thanks in advance.


More information about the IPython-user mailing list