What is self?

Self is merely a conventional name for the first argument of a method. A method defined as meth(self, a, b, c) should be called as x.meth(a, b, c) for some instance x of the class in which the definition occurs; the called method will think it is called as meth(x, a, b, c).

See also Why must ‘self’ be used explicitly in method definitions and calls?

CATEGORY: programming

 

Comment:

While I know that "self" is stated to be a convention, I bet that many new PyProgrammers will read right past that. Perhaps an example will