What is a classmethod for?

Dennis Peterson denpeterson at yahoo.com
Mon Jun 3 02:06:27 CEST 2002


> The point is that you can call class methods *without* creating an
> instance:

>C.foo()

But you can do that with a static method:

class C:
    def foo(x):
        print x
    foo = staticmethod(foo)

C.foo(1)

...much like Java static methods. I see the point there, I'm just trying to
figure out the purpose of the implicit class object in classmethod.

-Dennis







More information about the Python-list mailing list