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 Multiple Superclasses

many questions about multiplie superclasses!!

I am really confused, this video needs another video to clarify it, I have some questions to ask please help me to understand it because I feel lost :

  • What is the need for *args parameter? kenneth did not use it. -I can see that Sneaky and Agile classes did not have any parent, so what is the need for super() function?

super() function lets us call a bit of code from the parent inside the children class if this definition is wrong, please correct it for me

1 Answer

John Lack-Wilson
John Lack-Wilson
8,181 Points

Hi MoatazBellah, great questions!

All new classes that are created in Python are subclasses of the object class. Kenneth is using super() to set any fields that are passed from the *args and **kwargs parameters.

Heres a decent read about what *args and **kwargs are. If you have any questions about it drop a comment and I'll try my best to explain. Failing that, Kenneth does explain all this in other videos. If you follow along with the Beginning Python track you'll come across it sooner or later.

Thanks a lot :)

Philip Schultz
Philip Schultz
11,437 Points

Hey John, I have a question if you don't mind and I would greatly appreciate your help. My question is in regards to your statement above "Kenneth is using super() to set any fields that are passed from the *args and **kwargs parameters."

Are you suggesting that all variables are being packed in args and kwargs, then unpacked in each init method to check if there are matching fields, if there is a matching kwarg the value will stay, if there isn't a matching field they will be packed up again in kwargs and move to the next class in the MRO line, where it will do the same thing (unpack, check for fields, packup, go to the next)?

I really appreciate your help, I must have watched this video 10 times now and I'm not following. Thanks,