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

Arcee Palabrica
Arcee Palabrica
8,100 Points

Clarification on TypeError: __init__ is missing a required positional argument 'name'

Hey guys can anyone clarify why is it that by the time the name value goes to the super calls it's lost its positional argument and doesn't put name as the first argument that is provided?

2 Answers

Seth Kroger
Seth Kroger
56,407 Points

Though you haven't shown any code to pin down the error, super() is a function call just like any other. If there are any arguments to be passed they need to be included just like a regular function.

Arcee Palabrica
Arcee Palabrica
8,100 Points

Seth Kroger thanks man. Sorry I didn't put the error ? But I was actually referring to the video Multiple Superclasses when Kenneth Love made the Character class the final class before he ran into an error. I think that was around minute 4 or something. And how did name="" resolve the error?

The reason his code failed is because in the init() function of his Character class, there was no *args parameter, only (self, name, **kwargs). This means that even though the name parameter is passed into the Sneaky class' init, it is not expected to come through into the Character init and is disregarded. Kenneth fixed the issue by making name a kwarg, since kwarg is written into the Character class' list of init parameters, but you could also fix the problem by adding in the *args to the list of Character init() parameters.