[Python-porting] Pickling unbound methods on Python 3
"Martin v. Löwis"
martin at v.loewis.de
Sat May 29 20:43:55 CEST 2010
> I know that unbound methods are of the function type in Python 3. I'm
> calling them unbound methods because they are methods of classes which
> are not bound to an instance. I'm aware they have no special stance, but
> I still refer to them as unbound methods.
Neglecting reality doesn't help your cause, though. You'll need to
understand *why* pickling fails, and then see whether there might be
a solution.
A work-around is to put all methods you want to pickle into module-scope
of your module
class Foo:
def bar(self):
pass
bar = Foo.bar
Now you can pickle Foo.bar.
Regards,
Martin
More information about the Python-porting
mailing list