"Enabling" comparison for classes

You can use the total_ordering decorator from functools, which generates all the missing compare methods if you supply __eq__() and one other.

Given a class defining one or more rich comparison ordering methods, this class decorator supplies the rest. This simplifies the effort involved in specifying all of the possible rich comparison operations:

The class must define one of __lt__(), __le__(), __gt__(), or __ge__(). In addition, the class should supply an __eq__() method.

For Example,

@total_ordering
class Student:
    def _is_valid_operand(self, other):
        return (hasattr(other, "lastname") and
                hasattr(other, "firstname"))
    def __eq__(self, other):
        if not self._is_valid_operand(other):
            return NotImplemented
        return ((self.lastname.lower(), self.firstname.lower()) ==
                (other.lastname.lower(), other.firstname.lower()))
    def __lt__(self, other):
        if not self._is_valid_operand(other):
            return NotImplemented
        return ((self.lastname.lower(), self.firstname.lower()) <
                (other.lastname.lower(), other.firstname.lower()))

Define or override the comparison operators for the class. http://docs.python.org/reference/expressions.html#notin

Looks like you are on the right track, except you only need to pass the second circle object to your comparison. self refers to the first circle object. So self.r would give you the r of the first circle. Also you need to return True or False from the method.

def __gt__(self, circle2):
    return self.r > circle2.r

Note that this is just comparing the r's of the circles.