The first argument of each method of the python class must be an instance of the class itself. By convention self, this is a keyword that is used to indicate an instance of a class. There is no reason to use a different keyword, and you should not stick to the agreement self:). When a class method is defined, the argument selfmust be included; however, when the class method is used, the argument is selfimplicitly present.
Example:
class C:
def cMethod(self, a1, a2):
pass
[...]
>>> cinstance = C()
>>> cinstance.cMethod(x1, x2)
I just wanted to point out two aspects :). Bye
source
share