To support methods, you see that an instance of the class needs to be passed.

Understand self better by building a class in Python yourself.

What if Python would not have classes? In this video you learn how to emulate a class by using a dictionary. To support methods, you see that an instance of the class needs to be passed. Once you start to name this parameter 'self', it becomes clear why methods take self as the first parameter.

Written by Loek van den Ouweland on 2021-06-22.
Questions regarding this artice? You can send them to the address below.