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 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]

1 Answer

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!