method = Klass.othermethod considered PITA
Steven Bethard
steven.bethard at gmail.com
Sun Jun 5 11:45:19 EDT 2005
John J. Lee wrote:
> Steven Bethard <steven.bethard at gmail.com> writes:
>>In Python 2.4:
>>
>>py> class A(object):
>>... def foo(self):
>>... print 'foo'
>>... bar = foo
>>...
>>py> import pickle
>>py> pickle.loads(pickle.dumps(A)).bar
>><unbound method A.foo>
>>py> pickle.loads(pickle.dumps(A())).bar()
>>foo
>
> I meant class instances.
Look closer. The second example pickles and unpickles an instance of
class A.
STeVe
More information about the Python-list
mailing list