PyDocs

Nav

Python Runtime Services

staticmethod

builtins

decorator
  • @staticmethod
Convert a function to be a static method.

A static method does not receive an implicit first argument.
To declare a static method, use this idiom:

     class C:
         @staticmethod
         def f(arg1, arg2, argN):
             ...

It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()). Both the class and the instance are ignored, and
neither is passed implicitly as the first argument to the method.

Static methods in Python are similar to those found in Java or C++.
For a more advanced concept, see the classmethod builtin.
Changed in 3.10
  • 3.10: Static methods now inherit the method attributes (__module__, __name__, __qualname__, __doc__ and __annotations__), have a new __wrapped__ attribute, and are now callable as regular functions.
0 Examples
No examples for builtins/staticmethod.
See Also
No see-alsos for builtins/staticmethod
0 Notes
No notes for staticmethod