More fun with PEP 276

Jeff Shannon jeff at
Mon Dec 17 13:46:01 EST 2001

James Althoff wrote:

> Are they better than xrange?  At least for the case of
> a decreasing, open-on-the-left, closed-on-the-right
> interval with variable bounds they seem more natural
> (I would claim):
>     for i in xrange(a-1,b-1,-1):
> versus:
>     for i in a > ints() >= b:

Note that, for most purposes, this would be almost equivalent to

    for i in xrange(b, a)

which evaluates in the opposite order but provides all the same
values.  (Yes, there are some cases where order of evaluation
will matter, but these are *not* common cases.)  I still think
that any fancy range/interval notation is a solution in search of
a problem--the cases where the current range() behavior is not
appropriate, are rare enough that having that much variety of
syntax would be more likely to cause confusion than simplify

Jeff Shannon
Credit International

More information about the Python-list mailing list