PEP 276 Simple Iterator for ints

David Eppstein eppstein at ics.uci.edu
Thu Nov 15 11:32:49 EST 2001


In article <mailman.1005820294.7774.python-list at python.org>,
 Skip Montanaro <skip at pobox.com> wrote:

> I think I would still write the above as
> 
>     for rowcount in [0, step, ... table.getRowCount()]:
> 
> That would get you the sequence
> 
>     0, 1*step, 2*step, ... (table.getRowCount()-1)*step
> 
> and is more flexible than your proposal.  There's no reason you couldn't
> have
> 
>     for f in [0.0, 1.0, ... sys.maxint]:
> 
> to enumerate floats up to but not including sys.maxint (care needs to be
> taken to not to compound errors).
> 
> You could also build character sequences I think:
> 
>     for c in ["a", "b", ... "z"]:

You seem to be inconsistent here about whether you want these ranges to be 
open or closed on the right.  I think closed is the only reasonable choice 
for this syntax.
-- 
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