News for hackers. Stuff that matters.
Re:The Python Unicode Mess by guitarbill on Saturday October 06, 2018 @04:57PM (#18157225)
Not quite with ==, but there is precedence where operators with basic builtin types throw a TypeError when the operation doesn't make sense:

    >>> 0 > None
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: '>' not supported between instances of 'int' and 'NoneType'
Re:The Python Unicode Mess by wool_gather on Saturday October 06, 2018 @05:51PM (#18157457)
Absolutely; there's no good boolean answer for > when you have different types, so the `TypeError` is perfect there.
Re:The Python Unicode Mess by ubernostrum on Saturday October 06, 2018 @11:58PM (#18158776)
At the same time, this result is entirely dependent on the types involved. For example, "1.0 > 0" has a well-defined answer, and Python returns it.

Considering the expression "x > y", the full process is:

1. Call x.__gt__(y).

2. If that returns a bool, that's the result. If it raises an exception, propagate the exception.

3. If it returns the sentinel value NotImplemented, attempt the reflected version of the operation: y.__lt__(x).

4. If that returns a bool, that's the result. If it raises an exception, propagate the exception.

5. If it returns the sentinel value NotImplemented, raise TypeError and inform the programmer this operator is not valid on these types.