can't pickle instancemethod objects
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Sun Jul 9 12:23:03 EDT 2006
On Sun, 09 Jul 2006 08:39:29 -0700, Jim Lewis wrote:
>> I'd suggest that "pop" could be your culprit. ...What is pop? A function or an instance method?
>
> Neither. pop is an instance of a class, like:
> class X:
> ...
> pop = X ()
>
> pop surely is the culprit but it has arrays of objects, etc., and I
> don't know what to look for.
I'd start by looking for an attribute of pop that holds a reference to
some function or method. E.g. something like this:
class X():
def method(self):
pass
def __init__(self):
self.L = [1, "a", X.method] # note the lack of ()s
pop = X()
Otherwise, I'm working blind without knowing more about your class.
Here's a thought: comment out every attribute in your class, and then try
pickling it. If it succeeds, uncomment just *one* attribute, and try
pickling again. Repeat until pickling fails.
--
Steven.
More information about the Python-list
mailing list