Operator overloading allows for changing how operators work for types that are user-defined. Suppose you have the following example:

class Person:

    def __init__(self, name, age):
        self.name = name
        self.age = age

We then create two objects of the above class like so:

person1 = Person('Peter', 34)
person2 = Person('Sally', 25)

We can then use operator overloading to compare the two objects above using their age:

class Person:

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __gt__(self, other):
        return True if self.age > other.age else False

We can then compare the ages in both objects in the following manner:

print(person1.age > person2.age) # True