Why is “!=” used with iterators instead of “

All iterators are equality comparable. Only random access iterators are relationally comparable. Input iterators, forward iterators, and bidirectional iterators are not relationally comparable. Thus, the comparison using != is more generic and flexible than the comparison using <. There are different categories of iterators because not all ranges of elements have the same access properties. … Read more

Python’s in (__contains__) operator returns a bool whose value is neither True nor False

You are running into comparison operator chaining; 1 in () == False does not mean (1 in ()) == False. Rather, comparisons are chained and the expression really means: (1 in ()) and (() == False) Because (1 in ()) is already false, the second half of the chained expression is ignored altogether (since False … Read more