__gt__

Dunder MethodPython 2.0+Intermediate

Defines behavior for the > greater-than operator

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
class Example:
    def __gt__(self):
        return "Example __gt__"

obj = Example()
print(obj)

__gt__ defines behavior for the > greater-than operator. Implementing it lets you customize how Python interacts with your objects.

Try in Playground

Tags

oopmagic-methodprotocolcore