+ 1
I am confused about the lesson on static methods in python. What is difference between a static method and a class method?
8 Respuestas
+ 5
Well static method dont have self as their first agrument.They dont use instance variable.They are related to class but not to any object or its instances.
On the other hand class methods have self as their first argument and use instance variables.
+ 4
Static methods are not bound to any object.They are bound to class but not objects.
+ 3
Thanks 🌛DT🌜 . I just saw what I was looking for.
+ 3
Yes it not as useful as class method.
+ 2
Thank you mitali jadhavrao. I understand now. I just feel @staticmethod is not very useful.
+ 2
and very good for those people who like programs and software engineering you learn some command and also you can do some cool games and site
+ 1
mitali jadhavrao but you can call both @classmethod and @staticmethod from a class or from an instance. Except for the fact that cls is passed as first argument for class method and none is passed for static method.. I wonder what is the use for @staticmethod