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

Trying to get it to recognize Double

Syntax error???

doubler.py
class Double(int):
    def__new__(int)
    self = int.__new__(self)
    return self

2 Answers

Steven Parker
Steven Parker
231,275 Points

There's a few issues:

  • there should be a space after the keyword "def"
  • the instructions say that the "method should accept self and one argument"
  • the method code lines need to be indented more than the "def" line
  • the instructions say to "Convert the argument to an int and return it."

I will try again

After some serious "rubber ducking," here's what passed that challenge: def new(self, int): return int * 2 After some experimentation I found that int * 2 passed the third echelon of this code challenge! Seriously, thank you :)

Steven Parker
Steven Parker
231,275 Points

Congratulations! But in future you might also want to avoid using a special keyword (like "int") as a variable name.

Yes, I don't understand why they insisted on using a special keyword like "int." I would have rather used something else more appropriate like maybe "init." Or anything along those lines

Steven Parker
Steven Parker
231,275 Points

The "int" specified with the class is necessary, and is the keyword. But the terms on the "def" line are parameter names that you choose. Avoiding keywords or common function names can prevent errors that can be hard to track down.