On 29 August 2000, Ka-Ping Yee said: > I think these examples are beautiful. There is no reason why we couldn't > fit something like this into Python. Imagine this: > > - The ".." operator produces a tuple (or generator) of integers. > It should probably have precedence just above "in". > > - "a .. b", where a and b are integers, produces the sequence > of integers (a, a+1, a+2, ..., b). > > - If the left argument is a tuple of two integers, as in > "a, b .. c", then we get the sequence of integers from > a to c with step b-a, up to and including c if c-a happens > to be a multiple of b-a (exactly as in Haskell). I guess I haven't been paying much attention, or I would have squawked at the idea of using *anything* other than ".." for a literal range. > If this operator existed, we could then write: > > for i in 2, 4 .. 20: > print i > > for i in 1 .. 10: > print i*i Yup, beauty. +1 on this syntax. I'd vote to scuttle the [1..10] patch and wait for an implementation of The Right Syntax, as illustrated by Ping. > for i in 0 ..! len(a): > a[i] += 1 Ugh. I agree with everythone else on this: why not "0 .. len(a)-1"? Greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4