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 Super-Duper!

Jacob Rummel
Jacob Rummel
3,103 Points

Getting TypeError when trying to follow along with Kenneth here [Solved]

Here's my code that I thought looks the same as Kenneth's:

class Character:  
    def __init__(self, name, **kwargs): 
        self.name = name 

        for key, value in kwargs.items(): 
            setattr(self, key, value) 


class Thief(Character): 
    sneaky = True 

    def __init__(self, name, sneaky=True, **kwargs):
        super().__init__(self, name, **kwargs)
        self.sneaky = sneaky

But I'm getting this traceback:

TypeError: init() takes 2 positional arguments but 3 were given.

Getting that error regardless of how many arguments I actually use in initialization.

[MOD: marked title as "Solved" -cf]

Jacob Rummel
Jacob Rummel
3,103 Points

Figured out my mistake!

I had the super()__init__call taking self as a parameter and that was screwing things up. I had gotten into the habit of putting self into everything when working with classes!