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 Advanced Objects Double

Matt Brake
Matt Brake
9,799 Points

Task 2 passes without overriding __new__()

Why does this pass even though I'm not overriding new()?

If I'm not doing this correctly what do I need to do?

doubler.py
class Double (int):
    def add(self, value):
        self += value
        return self

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Very interesting question! Without explicitly overwriting __init__, the inherited method int.__init__() will be run. Apparently, the running the inherited __init__ is sufficient to pass Task 2. But then you would end up explicitly adding the missing __init__ to solve Task 3.

Tagging Kenneth Love to review if having no __init__ present is Task 2 is acceptable.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

That'll pass task 1 and 2 because those two tasks are just creating a subclass. Your add() is 100% superfluous and ignored in the challenge, btw.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Added a check for def __new__ in step 2.