An implementation of a variation on "for 1 <= i <= 10" [was Re: PEP 276 Simple Iterator for ints (fwd)]

David Eppstein eppstein at ics.uci.edu
Thu Dec 6 20:45:07 EST 2001


In article <slrna105a1.4mg.QnickQm at h00104b6bfa23.ne.mediaone.net>,
 QnickQm at alum.mit.edu (Nick Mathewson) wrote:

> Here's some code that implements almost this behavior.  Now you can type:
> 
> for i in 1 <= ints <= 10:
>    print i

Cool.

It looks like you haven't added the logic yet to make
    for i in x < ints <= y
work correctly when x and y are not known to be integers,
but range() doesn't take nonintegers either
(according to the Python 2.1 Library Reference, anyway).
-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list