Static method can be called without creating an object or instance. Simply create the method and call it directly.
This is in a sense orthogonal to object orientated programming: we call a method without creating objects.
Related course: Complete Python Bootcamp: Go from zero to hero in Python
Demonstration of static method below. Define a class with a method. Add the keyword @staticmethod above it to make it static.
A class can contain both static and non-static methods. If you want to call non-static methods, you’ll have to create an object. The code below does not work because an object is not created:
If we create an object, we can call non-static methods: