Python Object-Oriented Python Inheritance Multiple Superclasses

MoatazBellah Ghobashy
MoatazBellah Ghobashy
9,252 Points

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,161 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.

Philip Schultz
Philip Schultz
11,322 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,