4 ms·
I think the comparison is more readable as (here with the >>> of the python shell): >>> 0 < x < 1 as opposed to >>> 1 > x > 0 Following the number l
by myg204 12y ago
I think the comparison is more readable as (here with the >>> of the python shell):
>>> 0 < x < 1
as opposed to
>>> 1 > x > 0
Following the number line and placing x there is nicer IMHO.
Other than that, very nice trick.
- dllthomas 12y agoIn terms of coding style, I agree with you that following the number line is usually going to be clearest. I think there might be some situations where descending is better than ascending, but certainly both are radically better than what I did above (low > high < lower). As an example for what I was specifically trying to show here, though, that doesn't let me distinguish things quite as clearly. I believe that (a < x < b) gives the same value as at least one of (a < x) and (x < b) for any value of x. x < a: a < x gives false a < x < b gives false a < x < b: everything gives true b < x: x < b gives false a < x < b gives false So there's no way to get both of the parenthesized versions to disagree with the unparenthesized version in a single example.