> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Greater Than

The `>` (greater than) operator is a strict inequality relational operator that evaluates whether the left operand is strictly greater than the right operand, returning a boolean value (`True` or `False`).

```python theme={"dark"}
left_operand > right_operand
```

## Underlying Implementation

At the object level, the `>` operator is mapped to the `__gt__` magic (dunder) method. Because Python looks up magic methods on the class rather than the instance dictionary, the internal equivalent relies on `type()`. When the Python interpreter encounters `a > b`, it executes the following method resolution order:

1. **Subclass Priority:** If the right operand (`b`) is an instance of a strict subclass of the left operand's (`a`) type, Python prioritizes the subclass's reflected method and calls `type(b).__lt__(b, a)`.
2. **Standard Lookup:** Otherwise, Python calls `type(a).__gt__(a, b)`.
3. **Reflected Fallback:** If the first attempted method returns the `NotImplemented` singleton (indicating the type does not support comparison with the other type), Python attempts the reverse operation: `type(b).__lt__(b, a)` (assuming it was not already attempted in step 1).
4. **Exception:** If both methods return `NotImplemented`, Python raises a `TypeError`.

```python theme={"dark"}

# Internal equivalent of a > b (standard lookup)
type(a).__gt__(a, b)
```

## Evaluation Mechanics by Data Type

The behavior of the `>` operator depends strictly on the implementation of `__gt__` for the types being compared:

* **Numeric Types (`int`, `float`, `Decimal`, `Fraction`):** Evaluates the mathematical value. Python handles cross-type numeric comparisons automatically (e.g., comparing an `int` to a `float`) without explicit casting.
* **Strings (`str`):** Performs a lexicographical comparison based on the Unicode code point values of the characters, evaluated via the built-in `ord()` function. Comparison proceeds character by character from left to right until a difference is found.
* **Sequences (`list`, `tuple`):** Evaluates lexicographically, element by element, starting at index `0`. The comparison terminates at the first unequal pair of elements. If one sequence is an initial subsequence of the other, the longer sequence is considered greater.
* **Sets (`set`, `frozenset`):** Evaluates for a strict superset relationship. `set_a > set_b` returns `True` only if `set_a` contains every element of `set_b`, and `set_a` has at least one element not present in `set_b` (i.e., `len(set_a) > len(set_b)`).

## Operator Chaining

Python supports chaining of relational operators.

```python theme={"dark"}
a > b > c
```

At the AST (Abstract Syntax Tree) level, chained comparisons are represented as a single `Compare` node with multiple operators and comparators, rather than being internally translated into a boolean `and` operation (`BoolOp`). While *conceptually* equivalent to `a > b and b > c`, chaining evaluates the intermediate operand (`b`) exactly once. It also implements short-circuit evaluation; if `a > b` evaluates to `False`, the subsequent `b > c` comparison is never evaluated.

## Type Compatibility Restrictions

Unlike equality operators (`==`, `!=`), which safely fall back to identity comparison for incompatible types (where `==` evaluates to `False` and `!=` evaluates to `True`), the `>` operator enforces strict type checking. Attempting to compare inherently incompatible types (e.g., a `str` and an `int`) will raise a `TypeError` rather than coercing the types or falling back to object identity (`id()`).

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Python Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
