Range Operation pre-PEP

Roman Suzi rnd at onego.ru
Wed May 9 12:55:11 EDT 2001


On Wed, 9 May 2001, Thomas Heller wrote:

>> > At 12:23 09/05/01 +0200, Alex Martelli wrote:
>> > >Getting beginners used to inclusive-upper-end idioms
>> > >and then having them trip over exclusive-upper-end
>> > >ones elsewhere later is NOT doing them any favour.
>> >
>> > Ok, I'm in brainstorm mode. You're warned :-) Some weird ideas are just
>> > popping out of my mind:
>> >
>for i in [0:10):
>    print i
>
>for i in [0:10]:
>    print i
>
>Thomas

Please, recall the main reason for the new feature:

- to allow beginners learn loops BEFORE they learn
lists and functions (which are needed now to explain
for-loop).

Even recursion could be explained without lists in Python,
why for-loops need this prerequisite?

It is not too expensive to write range(a,b,c) or
something similar, but cp4e needs cleaner way to do for loops.

If not ".." syntax, then any other, but with EXPLICIT
mentioning of the including/excluding nature of
ranges.

eg

for i from 1 to 10

for i from 1 before 11

for j from 1 to 100 step 2


-- these could be also used in list comprehensions consistently:

[i for i from 1 to 10]

*

But our discussion showed that there is probably no
much need in pushing ".." any more... :-(
because I see ".." as an only-for-novice feature
and we (who discuss) are no novices to judge...

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Wednesday, May 09, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Always remember no matter where you go, there you are." _/





More information about the Python-list mailing list