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

26.4. Static methods

A static method of a Python class is a method that does not obey the usual convention in which self, an instance of the class, is the first argument to the method.

To declare a static method, declare the method normally, and wrap it with the built-in staticmethod function, using either of the techniques described in Section 21.20, “staticmethod(): Create a static method”.

Once you have declared a method to be static, the arguments you pass it are exactly the arguments it receives. Example:

>>> class Hobbs:
...     @staticmethod
...     def represent():
...         print "Hobbs represent!"
... 
>>> Hobbs.represent()
Hobbs represent!