classmethod() not inherited?

Jack Diederich jack at
Thu Jan 16 10:43:35 CET 2003

How is it possible to have classmethods still be
classmethods in their kids?

-- file --
class Base(object):
  def foo(cls):
    return 'BASE!'
  foo = classmethod(foo)

class A(Base):
  def foo(cls):
    return 'some value'

class B(Base):
  def foo(cls):
    return 'some other value'

class Z(Base):
  def foo(cls):
    return 'something else still'

I'd like to have ALL of the derivitives of Base
have foo as a classmethod, but it doesn't seem
to be automatic and the following doesn't work

import Test

for (Test.A .. Test.Z): # pseudo code = classmethod(

The Base class might have several classmethods
so adding all of them to each of the derivitives
is an error prone cut-n-paste nightmare.

google groups turns up lots of convos about type()
and new style classes, but I couldn't find anything
for this in particular.  [I'm Running Python 2.2.1]

hating cut-n-paste-ly yours,


More information about the Python-list mailing list