[Python-3000] optimizing [x]range (original) (raw)
Georg Brandl g.brandl at gmx.net
Sun Jul 29 07:41:58 CEST 2007
- Previous message: [Python-3000] optimizing [x]range
- Next message: [Python-3000] optimizing [x]range
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Johan Dahlin schrieb:
Guido van Rossum wrote:
Do we really need another way to spell a <= x < b?_ _FWIW, I'd say yes; I sometimes find it a bit difficult to remember_ _how the operator should be placed, there are several possible ways_ _of making a mistake, eg;_ _a > x < b_ _a < x > b a < x < b_ _a > x > b Now, the range syntax seems a bit strange at first, but I find it easier to parse: if x in range(a, b) There's no way to incorrectly parse that, it's immediately known that the programmer tries to see whether x is in a specific range.
What about floats?
Currently, "3.5 in range(5)" is False, while "0 <= 3.5 < 5" is True.
Georg
-- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
- Previous message: [Python-3000] optimizing [x]range
- Next message: [Python-3000] optimizing [x]range
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]