PEP 276 Simple Iterator for ints

Peter Hansen peter at engcorp.com
Wed Nov 28 19:10:12 EST 2001


James_Althoff at i2.com wrote:
> 
> And this might be handy in common situations where you could write, for
> example:
> 
> if index not in len(mylist):
>     print 'index out of range'
> 
> instead of
> 
> if index not in xrange(len(mylist)):
>     print 'index out of range'

What am I missing here?  Is the above not just 
a far less sane way of writing the following?

if index >= len(mylist):
    print 'index out of range'

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list