Next / Previous / Contents / TCC Help System / NM Tech homepage

18.4. Class methods

A similar new feature is the class method. As with static methods, a class method is not passed the instance as its first (self) argument. However, a class method is always passed a first argument containing the class object itself. You declare a method as a class method by following its declaration with a line of the form

f = classmethod ( f )

Here's an example:

class SpecialClass:
    ...
    def g(co, z):
        ...
    g  =  classmethod(g)

If called as SpecialClass.g(4), within method g z would be bound to the integer 4 and co would be bound to the class object SpecialClass.