switch recipe?
Emile van Sebille
emile at fenx.com
Sat Jul 13 10:56:50 EDT 2002
Mark McEahern
> Because I want to do something to the zipped items, it doesn't seem
like zip
> solves all my problems, though. map would, if it had the same
behavior as
> zip--namely that it stopped once one of the iterators ran out of
items.
> Below is a version that shows the use of zip. Here are the key lines:
>
> weaved = zip(iterator, alternator)
> generated = [color_item(x, y) for x, y in weaved]
>
> Perhaps what I'm still looking for is a way to
> weave-two-iterators-with-a-function all at once. One solution would
be to
> modify or wrap repeating_alternator() so that it was finite--then I
could
> just use map.
doesn't this do it?
generated = [color_item(x, alternator) for x in iterator]
(BTW, I nominate cycler as a name for alternator ;-)
--
Emile van Sebille
emile at fenx.com
---------
More information about the Python-list
mailing list