Message53542
| Author |
hinsen |
| Recipients |
| Date |
2002年05月20日.11:17:41 |
| SpamBayes Score |
| Marked as misclassified |
| Message-id |
| In-reply-to |
| Content |
Last week I noticed that the pickle and cPickle modules
cannot handle bound methods. I found a solution that is
simple and (I think) general, so perhaps it should
become part of the standard library.
Here is my code:
import copy_reg
def pickle_bound_method(method):
return getattr, (method.im_self, method.__name__)
class _Foo:
def bar(self):
pass
_foo = _Foo()
copy_reg.constructor(getattr)
copy_reg.pickle(type(_foo.bar), pickle_bound_method)
|
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2007年08月23日 16:02:13 | admin | link | issue558238 messages |
| 2007年08月23日 16:02:13 | admin | create |
|