PEP 284, Integer for-loops

David Eppstein eppstein at ics.uci.edu
Wed Mar 6 19:26:55 EST 2002


In article <mailman.1015456213.19181.python-list at python.org>,
 "Delaney, Timothy" <tdelaney at avaya.com> wrote:

> >     PEP 276 [4] proposes to allow automatic conversion of integers to
> >     iterators, simplifying the most common half-open case but not
> >     addressing the complexities of other types of interval.
> >     Additional alternatives have been discussed on python-list.
> 
> This is incorrect. PEP 276 proposes to make integers iterable. There is a
> significant difference, which I have noticed you either not understanding or
> ignoring.
> 
> I would suggest an amendment to PEP 284 to correct this.

When you say "incorrect", do you mean that "making integers iterable" is 
different from "allowing automatic conversion of integers to iterators"?
It was my understanding that "for x in y" and "if x in y" converted y to 
an iterator automatically, by calling iter(y) if necessary.  Integers 
can be made iterable now, by calling range() on them, but that is not 
automatic.

In what way would you propose rewording the PEP?  If it's just "PEP 274 
[4] proposes to make integers iterable, simplifying..." that seems 
unobjectionable enough.



More information about the Python-list mailing list