iterating "by twos"

Erik Max Francis max at alcyone.com
Tue Jul 29 16:12:48 EDT 2008


giltay at gmail.com wrote:

>      Whoops, I misread the original post.  That would be:
> 
> for x, y in zip(a[::2], a[1::2]):
>     frob(x, y)
> 
> ... which I don't use a lot.

Sorry, posted before I saw your reply.  Still, you're building three 
sublists in order to just iterate over them.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   Tell me the truth / I'll take it like a man
    -- Chante Moore



More information about the Python-list mailing list