Why do python need @staticmethod
📁 Decorator, method, Advanced Python Topics, AI
There is a class Printer. It has 2 methods that do the same. The difference is that one of the methods has a decorator @staticmethod, and the other does not. But I can call both methods without creating a class instance.
class Printer():
'''Test @staticmethod'''
def not_static_print(self, text='Example Text'):
print(text)
@staticmethod
def static_print(text='Example Text'): No answers yet.
Log in to leave an answer