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

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