[IPython-user] cPickle works in standard interpreter, but not in IPython
Fri Apr 17 14:50:27 CDT 2009
On 2009-04-17 13:09, Reckoner wrote:
> for example:
> In IPython:
>>> class Mylist(list):
> def __init__(self,x=):
>>> from cPickle import dumps
> 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
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from cPickle import dumps
>>>> class Mylist(list):
> ... def __init__(self,x=):
> ... list.__init__(self,x)
> Why is this?
The __main__ module is faked in IPython. You cannot pickle instances of classes
which were defined in the interpreter itself. This is an area that can be
improved, but it is quite tricky.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the IPython-user