What is __init__ and what is self?
Model answer
__init__ is the initialiser that runs when you create an object, to set up its attributes. self is the first parameter of instance methods and refers to the current object, so methods can read and change its attributes. Python passes it automatically.
Learn this topic
Classes and Objects in Python: A Gentle Introduction in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.