Python staticmethod() Function
Python staticmethod() function is used to convert a function to a static function. A static method is a method that belongs to a class rather than an instance of a class. The static methods do not require instantiation.
The staticmethod() method takes a single argument i.e. it takes a function as an argument.
The staticmethod() returns a static method of the function passed as the argument.
Example 1: Implementation for application of staticmethod()
In the above code a class with method greet() is created, then it was converted to the static method using staticmethod(), and it is called without creating an instance, as we have discussed earlier it is not required to create an instance of the class to call a static method.
Example 2: Implementation for application of staticmethod()
If we don’t require to use the class properties then we can use static methods, here in the above code add() method does not use any class properties so it is made static using staticmethod() and the diff method needs to be called by creating an instance because it uses class properties.