It does a lexicographical string comparison.
a > b
will resolve to:
a.__gt__(b)
in this case a is of type str, so it actually calls str.__gt__(b) with a as the bound instance. "gt" stands for "greater than".
x.__gt__(y) returns True if x is greater than y as defined by the function. If gt is not defined, it will fall back to using a.__cmp__(b). which returns -1, 0, 1 depending on the comparison result. If __cmp__ is not defined for type of a, this will result in a syntax error.
str has a __gt__ method so it is used for resolving a > b. You can supply this method for any of your custom objects.
See docs about rich comparisons lt, le, eq, ne, gt, ge and also cmp.