Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Inheritance Super-Duper!

why does the super() needs .__init__?

I think the video is quite poorly explaining why the super() method is implemented and specially why this super().ini is used.

3 Answers

Ari Misha
Ari Misha
19,323 Points

Hiya Eric! Unforunately, i kinda agree with ya. I didnt get it right away from videos, but i had to check out docs and stack overflow , in order to understand the concept of "super()" method. Ima keep it simple and short and i'll link you to a great post about why is "super()" an important concept in OOPs part of Python?

The "super()" references the parent class of the current class. Every class has a parent class and if you want to reference the parent class of the sub class, you need "super()" method up your sleeves.

"init()" method controls the initialization of object instances of the current class. If you wont override "init()" in the current class, it'll work in the default mode. But when you wanna override the __init__() method and control how your instances get initialized , you need to override it and add/custom the functionality of "init()" method that was happening behind the scenes earlier with the default mode.

Now, lets just say you'd like to reference a method of the parent class in your current class, all ya have to do is daisy chain the method "super()" to the class. Thats how you can modify the functionality of the current method in the sub class. And super().__init__() is something you'd come across a lot. Kenneth is just referencing the "init()" method of the parent with "super()" method.

here is the link i promised:

https://bytes.vokal.io/20151207-python-super-mro/

Hope it helped. (:

Yea, I think the concept is a little bit clearer now! I think it's hard to visualize in the video because there are very few methods in the parent class... I think... Anyway, thanks for the answer!

Herman Brummer
Herman Brummer
6,414 Points

Thanks that's a good link, I did not find that video useful at all. Actually, the OOP course is not that good compared to the other courses. Actually, I think this OOP section of the course needs to be redone, this stuff if complicated and needs to be carried across to students in the right way. Not saying that I have all the answers, but I don't feel this OOP section is helping me get to where I need to be.

Ari Misha
Ari Misha
19,323 Points

Dont worry! Everyone goes through the stage when things get overwhelming. And dont forget to visit the link i attached with comment coz i only touched the surface with "super()" method. There is a few more that you should go through. Anyways Good luck! (: