[Tutor] pickling/shelve classes
Eike Welk
eike.welk at gmx.net
Thu Jun 17 11:11:11 CEST 2010
Hello Payal!
On Thursday June 17 2010 04:48:19 Payal wrote:
> Hi all,
> Can someone please help in this below?
>
> class F(object) :
> ...: def __init__(self, amt) : self.amt = amt
> ...: def dis(self) : print 'Amount : ', self.amt
> ...: def add(self, na) :
> ...: self.amt += na
> ...: F.dis(self)
>
> pickle.dumps(F)
> gives PicklingError: Can't pickle <class '__main__.F'>: it's not found
> as __main__.F
I think it is a bug in IPython: I can do this in regular Python, but in
IPython I get the same error that you get:
Python 2.6.2 (r262:71600, Mar 29 2010, 15:30:01)
[GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class A(object):pass
...
>>> import pickle
>>> pickle.dumps(A)
'c__main__\nA\np0\n.'
>>>
You should file a bug report in their bug tracker:
http://github.com/ipython/ipython/issues
Eike.
More information about the Tutor
mailing list