+ 1

I am confused about the lesson on static methods in python. What is difference between a static method and a class method?

6th Jun 2018, 11:40 AM
IKECHUKWU, GAVIN C
IKECHUKWU, GAVIN C - avatar
8 Antworten
+ 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.
6th Jun 2018, 6:36 PM
Mitali
Mitali - avatar
+ 4
Static methods are not bound to any object.They are bound to class but not objects.
6th Jun 2018, 6:49 PM
Mitali
Mitali - avatar
+ 3
Thanks 🌛DT🌜 . I just saw what I was looking for.
6th Jun 2018, 12:02 PM
IKECHUKWU, GAVIN C
IKECHUKWU, GAVIN C - avatar
+ 3
Yes it not as useful as class method.
6th Jun 2018, 7:06 PM
Mitali
Mitali - avatar
+ 2
Thank you mitali jadhavrao. I understand now. I just feel @staticmethod is not very useful.
6th Jun 2018, 7:03 PM
IKECHUKWU, GAVIN C
IKECHUKWU, GAVIN C - avatar
+ 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
30th Jun 2018, 7:33 AM
willian postelaro
willian postelaro - avatar
+ 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
6th Jun 2018, 6:46 PM
IKECHUKWU, GAVIN C
IKECHUKWU, GAVIN C - avatar