code review

Terry Reedy tjreedy at udel.edu
Fri Jul 13 19:09:20 EDT 2012


>From now on, for each operator I would have to remember wether it
> is a supposedly comparison operator or not.

I believe the following rule is true: if a op b is True or False raises, 
then op is a potentially chained comparison operation. They are (not) 
equal (and (not) is), the 4 order comparisons, and (not) in. 'in' should 
be the only surprise and most confusing.
 >>> 1 < 3 in {3,4}
True
 >>> 3 in {3,4} < {4}
False

'and' and 'or' are not included because they do not always return a 
bool, and indeed, they are not binary operators in the usual sense 
because of short-circuiting.

-- 
Terry Jan Reedy






More information about the Python-list mailing list