Iterating over a function call
Gerald Britton
gerald.britton at gmail.com
Mon Feb 1 15:44:18 EST 2010
[snip[
> You have itertools.consume which is close to what you want:
>
> consume(imap(func, iterable)) # 2.x
>
> consume(map(func, iterable)) # 3.x
>
> HTH
It does! Though in my case this is simpler:
deque(imap(func, iterable), 0)
since the recipe for consume just calls deque anyway when you want to
eat up the rest of the iterable. It also solves the iterator-variable
leakage problem and is only a wee bit slower than a conventional
for-loop.
>
> --
> Arnaud
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Gerald Britton
More information about the Python-list
mailing list