PEP 276 Simple Iterator for ints

James_Althoff at i2.com James_Althoff at i2.com
Thu Nov 29 03:18:43 CET 2001


Peter Hansen wrote:
>Or just:
>
>if not 0 <= index < len(mylist):
>    print 'index out of range'

Right.  Which has the added advantage of not repeating index.

Or just, just:

    if not index in len(mylist):  # I know, I'm going around in circles
<wink>

Jim





More information about the Python-list mailing list