methods and class methods

Daniel Fetchinson fetchinson at
Tue Mar 31 17:30:26 CEST 2009

> I just learned python programming and is wondering how to change a method to
> a class method.

class x( object ):
    i_will_be_a_class_method( cls ): pass

> Also what are the differences between a method and class method.

A class method receives the class as its first argument while an
ordinary method receives the instance as its first argument. This fact
is reflected in the convention that for class methods the first
argument typically is called cls while for ordinary methods it's
called self.


Psss, psss, put it down! -

More information about the Python-list mailing list