loops

Duncan Booth duncan.booth at invalid.invalid
Sat Oct 18 16:42:47 EDT 2008


wbowers <william.bowers at gmail.com> wrote:

> I agree that using range() for simple iterations is the way to go.

except that as Terry said, "The large majority of use cases for iteration 
are iterating though sequences"

I very rarely use range() in iterations.

> Here are some examples of python expressions you'd use in specific
> situations:
> 

...

> # instead of for (i = 99; i >= 0; i--)
> for i in range(100)[::-1]: pass

or:
  for i in xrange(99, -1, -1): pass





More information about the Python-list mailing list