while (a=b()) ...

Quinn Dunkan quinn at groat.ugcs.caltech.edu
Tue May 18 21:10:25 EDT 1999


>A while back we hashed out a spelling for parallel iteration, as in:
>
>    for x in xlist; y in ylist:
>        print "I'm printed min(len(x), len(y)) times."

My method of doing this currently in python is

for x, y in map(None, xlist, ylist):
	foo()

Lightbulbs went off when I read the documentation and said "oh,
map(None, x, y, ...) is python's zip function!"

Coming from a functional background, my python experience was a bit different
than most people's: my rocks of stability were map, reduce, and lambda, and I
had some trouble figuring out how to use loops.

perpetuity = 1 : perpetuity
map somefunc perpetuity

:)

yes-you-can-iterate-in-haskell-ly yr's





More information about the Python-list mailing list