PEP 276 Simple Iterator for ints (fwd)

Delaney, Timothy tdelaney at avaya.com
Wed Dec 5 20:31:48 EST 2001


> From: Marcin 'Qrczak' Kowalczyk [mailto:qrczak at knm.org.pl]
> 
> Mon, 3 Dec 2001 19:27:46 +1100, Delaney, Timothy 
> <tdelaney at avaya.com> pisze:
> 
> >> I.e. it's translated to 'while' rather than to 'for i in range'.
> > 
> > Definitely not. The name receiving the value from the iterator
> 
> There is no requirement to implement this as using an iterator.

There is such a reqirement. All for loops from 2.2 on use iterators.

> I meant translating
> 
>     for 0 <= i < 10:
>         print i
> 
> into
> 
>     i = 0
>     while i < 10:
>         print i
>         i += 1
> 
> There is no iterator here.

This would not work with either the old or the new semantics of for loops.
It would mean that you would have for loops which in this one particular
case behaved differently to all other cases. That would classify as a severe
wart.

Tim Delaney




More information about the Python-list mailing list