Emulating classmethod in Python 2.1

Thomas Heller theller at python.net
Fri Jun 7 10:14:19 EDT 2002


"Hamish Lawson" <hamish_lawson at yahoo.co.uk> wrote in message news:915a998f.0206070611.295149d3 at posting.google.com...
> Thomas Heller wrote:
>
> > Here's the closest I came up with (you must rewrite your code to
> > derive SomeClass from object, the rest can remain unchanged). ...
>
> While ideally I was hoping not to have change any client code, your
> solution is the next best thing in requiring only a minimal change and
> in working with both Python 2.2's builtin classmethod() and with an
> emulating wrapper. Thanks!
>
You're welcome.
Note that you have to extend my code a little if you are
creating subclasses of SomeClass, but I'll leave that to you ;-).

I was astonished to see that classmethod() can be used in
classic classes, BTW.

Thomas





More information about the Python-list mailing list