method = Klass.othermethod considered PITA

Jeff Epler jepler at unpythonic.net
Sun Jun 5 01:35:43 CEST 2005


On Sat, Jun 04, 2005 at 10:43:39PM +0000, John J. Lee wrote:
> 1. In derived classes, inheritance doesn't work right:

Did you expect it to print 'moo'?  I'd have been surprised, and expected
the behavior you got.

> 2. At least in 2.3 (and 2.4, AFAIK), you can't pickle classes that do
>    this.

In all the versions of Python I've used, classes are pickled by name.
This example you wrote doesn't pose any special problem when pickling.

>>> pickle.dumps(A)
'c__main__\nA\np0\n.'
>>> pickle.dumps(B)
'c__main__\nB\np0\n.'

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050604/f43790f5/attachment.sig>


More information about the Python-list mailing list