Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
python3
keyword
self

What is 'self' in Python?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Whenever we create a class in Python, the programmer needs a way to access its attributes and methods. In most languages, there is a fixed syntax assigned to refer to attributes and methods; for example, C++ uses this for reference.

In Python, the word self is the first parameter of methods that represents the instance of the class. Therefore, in order to call attributes and methods of a class, the programmer needs to use self.