Range Operation pre-PEP

Roman Suzi rnd at onego.ru
Wed May 9 10:30:48 EDT 2001


On Wed, 9 May 2001, Carlos Ribeiro 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:
>
>1) Have both ':' and '..' as range operators. ':' excludes the last
>element, '..' includes it. This is a very simple rule-of-thumb. A beginner
>may be confused, but it's not something hard to learn.

I agree.

>
>2) Force the construct to be specified inside brackets or parenthesis,
>pretty much like list comprehensions.

This is what rejected PEP 204 is about...

>3) If (2) is approved, then the step operator becomes a natural extension
>of the list comprehension syntax:
>
> >>> [1..5 step 2]
>[1,3,5]
> >>> [1:5 step 2]
>[1,3]
>
>It's clear, readable and unambiguous.

Well, I do not pretend   (1, 2) .. 5 is the only way.
But "a .. b step c" is too... verbose.

>Carlos Ribeiro

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