PEP 276 Simple Iterator for ints (fwd)
David Eppstein
eppstein at ics.uci.edu
Tue Dec 11 12:25:03 EST 2001
In article <mailman.1008088402.31402.python-list at python.org>,
com-nospam at ccraig.org (Christopher A. Craig) wrote:
> > I said, the INTEGERS between x and y.
>
>
> I know it's what you said you wanted, but it's not what y > i >= x
> indicates for a float. Sure, the only reasonable default step size
> for floats is 1, but that doesn't mean I have to accept that y > i >= x for
> floats y and x means "integers such that y > i >= x". Your loop
To me, "for y > i >= x" indicates that i should take on every possible
value that makes y > i >= x true, just like "for i in L" indicates that i
should take on every possible value that makes i in L true. This is only a
reasonable thing to do if you restrict "every possible value" to integer.
The set of floats that make the inequalities true is just too big, and it
doesn't make sense to me to restrict to the floats that happen to be an
integer plus one of the bounds.
In other words, "step size" is a red herring, it happens to be true that
what I mean by "for y > i >= x" can be implemented by a range with stepsize
one, but that's not something I consider a primary part of the definition.
Maybe the suggestion of "for i in y > ints >= x" is better because it makes
the type declaration more explicit?
--
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