Static Methods

Use @staticmethod for utility methods that logically belong to the class but do not use self or cls.

PythonBeginner
Python
# Program to demonstrate static methods

class MathUtil:
    @staticmethod
    def is_even(n):
        return n % 2 == 0


print(MathUtil.is_even(4))
print(MathUtil.is_even(7))

Output

True
False

Static methods are namespaced inside the class but behave like plain functions without accessing instance or class state.