range syntax
Antoon Pardon
apardon at forel.vub.ac.be
Fri Nov 10 14:07:04 EST 2006
On 2006-11-10, Roberto Bonvallet <Roberto.Bonvallet at cern.ch> wrote:
> Colin J. Williams wrote:
>> One of the little irritants of Python is that the range syntax is rather
>> long-winded:
>> [Dbg]>>> range(3, 20, 6)
>> [3, 9, 15]
>> [Dbg]>>>
>> It would be nice if one could have something like 3:20:6.
>
> In that case, how would the parser know which colon terminates the
> 'for' in the following example:
>
> for i in 2:3:4:
> ...
By the programmer using parenthesis. Like
for i in (2:3):
...
Just as you are supposed to use parthesis if you
want a tuple as a function argument although normally
a comma is enough to form a tuple.
--
Antoon Pardon
More information about the Python-list
mailing list