Operators

> — Strict greater-than

Tests strict ordering in the greater direction. Sets interpret it as proper superset. Comparable sequences use lexicographic ordering rather than length alone. NaN is neither greater nor less than ordinary floats. A custom __gt__ may return a non-Boolean result. Rich comparisons share precedence and support chaining: the middle operand is evaluated once, and later operands are skipped when a preceding comparison is falsy. If both operands decline the comparison, ordering raises TypeError. Custom dispatch uses __gt__ and the counterpart __lt__ on the other operand; a right-hand subclass may have priority.

Formal Syntax & Structure

python syntaxpython
left > right

Parameters & Attributes

NameTypeDescription
leftobjectFirst operand; its type participates in operation selection.
rightobjectSecond operand; supported values depend on the operand types.

Return Value

bool or custom result

Boolean for ordinary built-in comparisons; custom rich comparison methods can return other values.

Working Example

Example Snippetpython
print(7 > 3)print("b" > "aa")print({1,2} > {1})
Python Reference