0
What is a static method and a class method in python ?
3 Respostas
+ 1
There is a pretty good explanation here:
https://realpython.com/instance-class-and-static-methods-demystified/
I think the key concept is, usually you would create an instance of a class, then you access the attributes of that specific instance via 'instance methods'.
With class methods you cannot change the attributes of an instance, only of the whole (abstract) class. And with static methods you cannot do either.
Also you can check this code and compare how I used a static and a class method (sometimes it makes not much difference to the result).
https://code.sololearn.com/c9z6qSA58rqQ/?ref=app
+ 1
Just complete the Python tutorial and you will get there :)
https://www.sololearn.com/learn/Python/2473/
0
So when should i use static method and when to go for class method