Range Operation pre-PEP

Roman Suzi rnd at onego.ru
Wed May 9 04:18:19 EDT 2001


On Wed, 9 May 2001, Greg Ewing wrote:

>If you want to get this considered, you'll have to
>make sure your PEP explicitly addresses all the reasons

I read them and found that almost all of them are caused
by using slice-like notation.

There are no more reasons to reject ".." than there are
reasons to obsolete range/xrange, because its just
a more newbie-frienly way to write them.


>for the rejection of PEP 204. (That might not be easy,
>since the rejection notice attached to PEP 204 is
>rather sketchy!)

I understand the rejection very well:

":" notation is very overused by the PEP 204.
(makes to much confusion).
IMHO, it's the main reason for Guido to reject it.


>One thing that comes to mind is the interpretation
>of the endpoint. The syntax strongly suggests that the
>endpoint is inclusive, as you propose. But this is
>not the most useful meaning in Python.

The reason under Python incl-excl nature is that
these are intermediate points, needed for slice-operations
to be natural like in:

a[0:0] = [1,2,3]


There is no reason to bring this into ".." notation, because
its different from ":" even visuall and it is more naturally
to use convenient incl-incl ranges.

Most of the
>time, range() is used in constructs such as
>
>  for i in range(len(mylist)):

These must be eliminated by use of maps, apply, etc -
by functional style.

>which would become
>
>  for i in 0..len(mylist)-1:
>
>The need to include the -1 is a nuisance and
>potential source of error.
>
>The alternative, making the endpoint exclusive,
>would make the meaning of the .. construct
>somewhat unintuitive.

I agree.

The fact, that there will be TWO ways for ranges doesn't
bother me, because the reason to include ".." into
Python is allowing beginners to appreciate more naturally
looking code than range(1,101).

I even think there is a need to rename ".." from range operation
to something other.

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