What is a classmethod for?
Terry Reedy
tjreedy at udel.edu
Sun Jun 2 16:22:45 EDT 2002
"Dennis Peterson" <denpeterson at yahoo.com> wrote in message
news:addgv30f4d at enews4.newsguy.com...
> class C:
> def foo(cls):
> print cls
> foo = classmethod(foo)
...
> That's nice, but I can't think of a use for it, given that we have
> inheritance and isinstance(). Can anyone enlighten me?
Suppose, more realistically, that .__init__() adds each instance to a
list of class instances. Then a reasonable classmethod would be one
that does something with that class attribute.
TJR
More information about the Python-list
mailing list