Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python Advanced Objects Subclassing Built-ins

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?

2 Answers

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 Nordell
Jennifer Nordell
Treehouse Teacher

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

The .lower() and .upper() are methods on instances of string. Just like append() and sort() are methods on an instance of a list.

In the example code we see:

class FilledList(list):

That means it is inheriting from list. So it has methods like sort() and append just like any normal list because it got it from its parent...list :smiley:

Hope this helps! :sparkles: