Range Operation pre-PEP
Alex Martelli
aleaxit at yahoo.com
Wed May 9 04:59:46 EDT 2001
"Greg Ewing" <see at my.signature> wrote in message
news:3AF8D070.B0ECF09A at my.signature...
[snip]
> The alternative, making the endpoint exclusive,
> would make the meaning of the .. construct
> somewhat unintuitive.
for x in seq[a:b]:
print x
versus
for i in a..b:
print seq[i]
My own intuition would expect the same behavior
from these two loops. I would consider it VERY
unintuitive to have them behave differently!!!
Maybe this should be accepted and reinforced
with a different syntax for the range, e.g.
for i in [a:b]:
print seq[i]
with the existing brackets-and-colons tokens
in lieu of the new proposed '..' token. Now
the fact that b is excluded, just as in s[a:b],
should perhaps be even more obvious...?
Alex
More information about the Python-list
mailing list