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 Proper Properties

Mikkel Bielefeldt
Mikkel Bielefeldt
3,227 Points

I don't see what's wrong

Not sure what's wrong here, I'm looking back and fourth on the video, and the code from last video, but I guess it's not as simple as I want it to be? Please help

rectangle.py
class Rectangle:
    def __init__(self, width, length):
        self.width = width
        self.length = length


    @area
    def __area__(self):
        return self.width * self.length

1 Answer

Steven Parker
Steven Parker
230,995 Points

You're pretty close, but instead of the property name, the decorator should just be the word "@property".

And in the definition itself, the property name doesn't need to be enclosed in double underscores. That's the convention for "magic" methods that are generally not invoked directly, such as __init__ there.

Mikkel Bielefeldt
Mikkel Bielefeldt
3,227 Points

Tried to do it again, but it still says try again.

 class Rectangle:
    def __init__(self, width, length):
        self.width = width
        self.length = length


    @property
    def area(self):
        return self.width * self.length
Steven Parker
Steven Parker
230,995 Points

That looks correct. :+1: Check the indentation in case it has mixed tabs and spaces, that's one possible problem that wouldn't show up here.

If that's not it, try restarting your browser.