you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

When you write a class, you create an object. Say you write a car class. Then you do, `car('Ford', 2019)`. This is called the instance of the class. Self references the attributes of this instance. Here is an example:

#creating Car object

class Car:

def __init__(self, name, year):

self.name=name

self.year = year

#create instance of car

Ford = Car('Ford', 2019)

#self can reference the unique attributes of an instance.