[Tutor] pickling/shelve classes

Payal payal-python at scriptkitchen.com
Thu Jun 17 04:48:19 CEST 2010


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

What is my mistake? I want to pickle and shelve classes as well as
instances.

With warm regards,
-Payal
-- 




More information about the Tutor mailing list