PEP 276 Simple Iterator for ints

William Tanksley wtanksle at dolphin.openprojects.net
Fri Nov 16 00:32:47 CET 2001


On Thu, 15 Nov 2001 13:20:41 -0800, Ken Seehof wrote:
>The `end' argument issue goes away if the slice returns an iterator, so
>int[:] returns the sequence of natural numbers [0, 1, 2, ...], which would
>be a useful idiom as an infinite for loop:

>.   for i in int[:]:
>.        print i
>.        do_something(i)
>.        if done(): break

I agree, but I don't think it should be legal to fail to give a starting
point.  So the above should be int[0:], not int[:].

>True, but having both would seem to be redundant, since you would not need
>both solutions which would be redundant.  Hence I am suggesting int
>slicing as an alternative to PEP 276 (did I say that already? :-)

I agree.

I, however, am also starting to wonder about this...  Aside from infinite
for loops, which DO seem very useful and not possible under the old
system, I've lost track of why we're arguing about this.  Why should we
make any change here?  What are we fixing?

>BTW, as a reminder, __getslice__ is depricated, so we are really talking
>about __getitem__(slice), which amounts to the same thing.

Sorry, I didn't know about that.

>- Ken

-- 
-William "Billy" Tanksley



More information about the Python-list mailing list