Take a look at the following example, which clearly explains the purpose of self
class Restaurant(object): bankrupt = False def open_branch(self): if not self.bankrupt: print("branch opened")#create instance1>>> x = Restaurant()>>> x.bankruptFalse#create instance2>>> y = Restaurant()>>> y.bankrupt = True >>> y.bankruptTrue>>> x.bankruptFalse
self
is used/needed to distinguish between instances.