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 Solution

Audrey Kale
Audrey Kale
1,690 Points

Does __eq__ not matter?

I tried with the dunder equal method and without it, and I get the same answer. Why does it not matter in this case? My theory is that by default, the program will compare the name attribute since that is the only parameter passed into class Dog. (But for classes with multiple attributes, the dunder equal method is necessary.) Is that right?

1 Answer

Steven Parker
Steven Parker
231,572 Points

By default, object comparison only looks for identity. So two different objects with the same content will not test as equal, but two references to the same object will.

Next time, be sure to show your code, but I'd guess what confused you this time is that you created a new reference to the same object and compared them instead of creating a new object instance.