iters on ints? (reducing the need for range/xrange)
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Fri Nov 9 12:09:54 EST 2001
9 Nov 2001 08:51:05 -0800, Michael Robin <me at mikerobin.com> pisze:
>>>> lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>>> # this works, or gives "list index out of range"
>>>> for i in len(lst): print lst[i]
> or
>>>> # this works, or really calls the fn eleven times
>>>> for i in 10: doSomethingTenTimes()
>
> Only one of these can work - the above are either equivalent to
> the interval [0..9] or [0..10]
No, they both work, because it would be equivalent to [0..9].
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^
QRCZAK
More information about the Python-list
mailing list