method = Klass.othermethod considered PITA

Steven Bethard steven.bethard at
Sun Jun 5 17:45:19 CEST 2005

John J. Lee wrote:
> Steven Bethard <steven.bethard at> 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>
>>py> pickle.loads(pickle.dumps(A())).bar()
> I meant class instances.

Look closer.  The second example pickles and unpickles an instance of 
class A.


More information about the Python-list mailing list