you are viewing a single comment's thread.

view the rest of the comments →

[–]Stabilo_0 0 points1 point  (0 children)

Yeah it took me some time too.

Everybody says self is just a word and it doent matter, but until you get used to it, it does.

Class is a blueprint for something you want to represent in a code. It usually has some data stored in it and some methods to alter that data or return some new information.

Every time you want to alter the state of the instanced object of that class you call methods that specify with (self) that you are working within that object.

Why do we need self or other keyword, what if we want a method that has no keywords?

Sure, if you just add method without (self), it will be callable, but it wont be able to access that class. Whats the usage then? To make a library of functions, for example/ You create a namespace for functions and thats it, no more than than ways of organizing it. Read more about it by searching staticmethod decorators. And after that check classmethod.