@staticmethod is a method in a class that doesn't receive self or cls. A regular function is standalone.
1class MathUtils:2 @staticmethod3 def add(a, b): # No self/cls4 return a + b56 @staticmethod7 def is_even(n):8 return n % 2 == 0910# Usage11print(MathUtils.add(2, 3)) # 512print(MathUtils.is_even(4)) # True1314# Also works on instance15m = MathUtils()16print(m.add(2, 3)) # 5
vs regular function:
When to use @staticmethod:
When to use regular function: