[Python-Dev] Inclusive Range
Cameron Simpson
cs at zip.com.au
Mon Oct 4 05:58:20 CEST 2010
On 03Oct2010 20:04, Eviatar Bach <eviatarbach at gmail.com> wrote:
| I have a proposal of making the range() function inclusive; that is,
| range(3) would generate 0, 1, 2, and 3, as opposed to 0, 1, and 2. Not only
| is it more intuitive, it also seems to be used often, with coders often
| writing range(0, example+1) to get the intended result. It would be easy to
| implement, and though significant, is not any more drastic than changing
| print to a function in Python 3. Of course, if this were done, slicing
| behaviour would have to be adjusted accordingly.
1: take this to python-ieas please instead of python-dev.
2: -1; the current behaviour is, IMHO, highly desirable.
Example:
x=3; y=7; z=12
s='ahahahahahahahaha'
assert s[:x]+s[x:y]+s[y:z]+s[z:] == s
No icky +1 hacks in there.
3: I find myself doing the +1 thing very _un_often, myself.
Cheers,
--
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
The hardest years in life are those between ten and seventy.
- Helen Hayes (at age 84)
More information about the Python-Dev
mailing list