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 Dice Roller Comparing and Combining Dice

We used __radd__ to add reflective additions to instances, why not now in the comparison methods? Thank you

When you create a class in python, you have to add both add and radd methods to make sure you can add them together, no matter which side of the operator the instance was on.

After defining the eq, ne, etc in this video, I tested out the methods in the terminal and they worked fine on both sides of the operator.

I'm probably missing something, but that was peculiar to me.

1 Answer

Josh Keenan
Josh Keenan
19,652 Points

This is because for these two options the order does not matter at all, it is a boolean operation so can only be True, or False, there are no other options.

The others though are saying, how do I add an integer to my die, and how do I add my die to an integer and preparing the class to handle this eventuality.

Hope this makes sense, feel free to ask any questions.

Yes, makes sense! Thank you for your answer