Please explain what is @staticmethod and @classmethod in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Please explain what is @staticmethod and @classmethod in python

7th Jan 2020, 3:12 AM
Rudra
1 Answer
+ 4
A regular method has 'self' as implicit first argument. This is the instance, that's supposed to be available in the method. With class methods, the class is instead passed. With static methods, nothing is passed. They behave like regular functions, only that they are in a class.
7th Jan 2020, 7:42 AM
HonFu
HonFu - avatar