staticmethod(function)
Return a static method for function.
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, ...): ...
The @staticmethod
form is a function decorator – see the description of function definitions in Function definitions for details.
It can be called either on the class (such as C.f()
) or on an instance (such as C().f()
). The instance is ignored except for its class.
Static methods in Python are similar to those found in Java or C++. Also see classmethod()
for a variant that is useful for creating alternate class constructors.
For more information on static methods, consult the documentation on the standard type hierarchy in The standard type hierarchy.
Please login to continue.