Adrian Diaz2,742 Points
Why use super() if there is no parent class?
Im confused as to how super works. I thought it was used to inherit a method from a parent class. If there is no parent class how is super still useful?
jayda hendrickson2,545 Points
Remember, Super() isn't just necessarily used to inherit methods from a parent class but to override methods that the parent class has assigned. By doing that it also inherits certain methods and overrides others that it wants to change
Jennifer NordellTreehouse Staff
Hi there, Adrian Diaz! There are parent classes. A
str() is making a new instance of a string. It's easy to think of them as "primitive data types" but they are contained in what is known as "object wrappers". Ever heard that everything in Python is an object?
name = "Adrian" print(name.upper()) # I am calling the upper method on the instance of string
.upper() are methods on instances of string. Just like
sort() are methods on an instance of a list.
In the example code we see:
That means it is inheriting from
list. So it has methods like
append just like any normal
list because it got it from its parent...
Hope this helps!