[Python-Dev] Lukewarm about range literals (original) (raw)

Skip Montanaro skip@mojam.com (Skip Montanaro)
Tue, 29 Aug 2000 09:46:23 -0500 (CDT)


Peter> I don't like [0...100] either. It just looks bad.  But I really
Peter> *do* like [0..100] (maybe that's Pascal being my first serious
Peter> language).

Which was why I proposed "...". It's sort of like "..", but has the advantage of already being a recognized token. I doubt there would be much problem adding ".." as a token either.

What we really want I think is something that evokes the following in the mind of the reader

for i from START to END incrementing by STEP:

without gobbling up all those keywords. That might be one of the following:

for i in [START..END,STEP]:
for i in [START:END:STEP]:
for i in [START..END:STEP]:

I'm sure there are other possibilities, but given the constraints of putting the range literal in square brackets and not allowing a comma as the first separator, the choices seem limited.

Perhaps it will just have to wait until Py3K when a little more grammar fiddling is possible.

Skip