Python Static Methods
Static methods are functions defined in a class that do not have access to the class object or any instance of that class. Static methods are called using the class, not an instance of the class.
class MyClass: @staticmethod def method(): return 42 MyClass.method() # Call the Static Method
Consider a mathematics class whose purpose is simply to collect together a set of methods for performing mathetical operations. You don't necessarily need to instantiate a mathematics object, nor does the class need to store any data. It's just a bunch of methods.
class MathUtilities: @staticmethod def add(a,b): return a + b @staticmethod def multiply(a,b): return a * b
You call the methods via the class name:
print(MathUtilities.add(1, 2)) print(MathUtilities.multiply(4, 5))