Iterating through two lists
Mats Kindahl
matkin at iar.se
Fri May 24 06:38:00 EDT 2002
jb <jblazi at hotmail.com> writes:
> I have two lists, x and y with the property len(x) = len(y).
>
> I should like to achive this (x is a list of class instances)
>
> for (a,b) in (x,y): a.f(b)
>
> Is there a fancy way of doing this or have I to introduce an auxillary
> counter (that is very easy but maybe not very "lispy", that is
> "python-like").
"zip", as in:
for (a,b) in zip(x,y): a.f(b)
I belive the function is coming from Haskell. That's at least where I
saw it first. Maybe somebody can confirm or deny that?
Best wishes,
--
Mats Kindahl, IAR Systems, Sweden
Any opinions expressed are my own, not my company's.
More information about the Python-list
mailing list