Self Parameter
Question
What is self in a Python method?
Hint
self is like this in other languages.
Explanation
self is a reference to the current instance of the class. It must be the first parameter of instance methods, though it is passed automatically when calling the method. Through self, you access instance attributes and other methods: self.name, self.method(). It is conventional to name it self, though any name works. Python does not have an implicit this like Java or C++.
Related Resources
Related Lessons
- Classes
Learn Python classes.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.