0
Purpose of Static Methods
i get @classmethods, they will spawn a new instance of the class, but @staticmethods? the only difference between just creating a method in a class and declaring it as a @staticmethod is that you dont have to pass a "self" to it, so why go through the trouble if declaring it at all, "self" is afterall shorter to type than "@staticmethod"
1 Réponse
+ 1
@static methods use nothing from the class itself, hence, why it's missing the self parameter that allows for it's own attributes and methods to be called.
If you write a method and find there was no reason to use any class attributes, it should be a static method