Check out a free preview of the full Intermediate Python course:
The "Class Instances" Lesson is part of the full, Intermediate Python course featured in this preview video. Here's what you'd learn in this lesson:

Nina introduces an example to illustrate how an instance of a class allows the user to call methods on the class that only refer to the bound instance.

Get Unlimited Access Now

Transcript from the "Class Instances" Lesson

>> Nina Zakharenko: But the kinda funny thing about Python, in languages like Java. You're kinda required to make getters and setters to modify stuff within your class. But Python is a little bit more willy-nilly, so I can just go and change the value of dot runs for my Subaru for my instance.

[00:00:26] I don't necessarily need to use a getter or a setter. Using them is a best practice in software projects to take out some of the mystery, but you're not gonna get a syntax error. Python's not gonna stop you from doing this type of modification. So now if I call my_subaru.start and it takes the name, so I'm gonna have to pass one in it again.

[00:00:50] What will I see printed out?
>> Speaker 2: Broken set.
>> Nina Zakharenko: All is broken, time to do more front end masters classes to pay for the repair.
>> Speaker 2: [LAUGH]
>> Nina Zakharenko: Okay, so that self variable that refers to an instance, and if I make a new car.
>> Nina Zakharenko: Let's call it a mustang car.

>> Nina Zakharenko: If I check runs on mustang car, what will I get?
>> Nina Zakharenko: It's true, right? So the changes that I made to my Subaru only applied to my_subaru instance.