[Python-3000] optimizing [x]range
skip at pobox.com
skip at pobox.com
Sun Jul 29 14:18:49 CEST 2007
Johan> FWIW, I'd say yes; I sometimes find it a bit difficult to
Johan> remember how the operator should be placed, there are several
Johan> possible ways of making a mistake, eg;
Johan> a > x < b
Johan> a < x > b
Johan> a < x < b
Johan> a > x > b
If the two angles face the same way it's correct. It's hard to see how it
could be any other way.
Johan> Now, the range syntax seems a bit strange at first, but I find it easier
Johan> to parse:
Johan> if x in range(a, b)
You can't spell
a <= x <= b
or
a < x < b
without remembering to add or subtract 1 from the appropriate endpoint
if x in range(a, b+1)
if x in range(a-1, b)
That would seem to me to be more error-prone than confusion about
a < x < b
Skip
More information about the Python-3000
mailing list