Function Details: staticmethod

Description


Transforms a method into a static method.


Extended Description


The staticmethod decorator is used to declare a method as a static method. Unlike regular methods, static methods don't receive an implicit first argument (usually named 'self' for instance methods or 'cls' for class methods). They can be called on the class or an instance of the class, but they don't have access to the instance or class through an implicit first parameter. Static methods are often used for utility functions that don't need to access or modify the class state.


Read More about staticmethod from Python Documentation

Function Signature


@staticmethod
def function(*args, **kwargs) -> Any

Module: builtins

Class: staticmethod

Parameters



Parameter List


  • function: Callable

Return


Returns a static method for the given function.


Return Type


staticmethod

Output

Explanation

This example shows how to define and use static methods in a class.