PEP 276 Simple Iterator for ints (fwd)

Delaney, Timothy tdelaney at avaya.com
Mon Dec 3 03:27:46 EST 2001


> If the body inside the loop rebinds the iteration variable 
> (not a great
> idea but we must give it some meaning), it's IMHO reasonable to let
> it continue iteration from the new value. I.e. it's translated to
> 'while' rather than to 'for i in range'.

Definitely not. The name receiving the value from the iterator will *always*
be rebound to the object returned from the iterator's next() method. In the
case of the proposed syntax, it would *always* be the next integer in the
specified series.

In fact, it would be impossible to do what you are suggesting unless you
were going to have some way to inform the iterator that the name which
received its value had been rebound. In which case you would require that
for every iterator.

Tim Delaney




More information about the Python-list mailing list