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.
Andy McDonaldPython Development Techdegree Student 8,745 Points
I have no idea whats going on -- overridding __new__
Kenneth is talking about ovverridding magic methods and i dont really know what this whole video is talking about. The quiz is asking me to override new. I dont even know what to ask...
class Double(int): def __new__(**args, **kwargs): super().__new__(**args, **kwargs) return __new__(**args, **kwargs)
Mel RumseyTreehouse Staff
Hey Andy McDonald !
You are fairly close with the code you currently have. There are just a few things to change.
class Double(int): def __new__(**args, **kwargs): super().__new__(**args, **kwargs) # this line can be removed return __new__(**args, **kwargs)
*args should only have 1 asterisk in front of them. Otherwise the python interpreter is reading it as if it has keywords.
Second, we only want to return a created instance of
int that sets the value of
__new__ to the passed in
**kwargs. To create an instance, you can put
int. in front of
__new__(*args, **kwargs) when you return it.
I hope this helps. Don't hesitate to reach back out if you are still stuck :)