What makes a language object oriented?


What makes a language object oriented?


We’ve learned so far about a few of the concepts that are core in almost any object-oriented language. The big three features typically associated with object orientation are polymorphism, encapsulation, and inheritance.
For the purposes of this course, it’s plenty to understand that objects can inherit from each other, can define how their data is accessed, and how to create and use classes and objects.
If you’re up for a challenge, a quick Google search for those other object-oriented properties will provide a rabbit hole to keep you busy for days! To start you off, this StackOverflow post’s top answer gives some great insights about what defines object orientation.



Why is there no def init in Class ReturningCustomer?

1 Like

When we created the ReturningCustomer class, we created it with inheritance as a subclass of the Customer class like this:

class ReturningCustomer(Customer):

When Python tries to create the ReturningCustomer object and sees it has no __init__ function, it knows that ReturningCustomer is a kind of Customer thanks to that line, and then looks in the Customer class for its __init__ function. (Notice that Python only checks the Customer class after it checks the ReturningCustomer class. This is covered in more detail later on in the lesson.) Python uses this same reasoning to execute the display_cart method for our monty_python instance of the ReturningCustomer class, even though that function is only defined in the Customer class.