What is `self`, and why must it be listed explicitly as the first parameter of every instance method?
Answer
`self` is simply the conventional name for the parameter that receives the instance a method is being called on; Python does not use an implicit `this` like some other languages. When you write `obj.method(arg)`, Python translates that into `ClassName.method(obj, arg)` under the hood, so the instance is always passed as the first positional argument, and the method signature must accept it explicitly. `self` is a naming convention, not a keyword — any name would work, but every Python style guide expects `self`.
Strong answer includes
- self receives the instance the method is called on
- obj.method(arg) is translated to Class.method(obj, arg)
- self is convention, not a reserved keyword
Practical example
instance.greet()and
Person.greet(instance)call exactly the same underlying function with exactly the same arguments; `self` inside `greet` refers to `instance` either way.