[Python-Dev] [rfc] map enhancement

Raymond Hettinger python@rcn.com
Wed, 19 Feb 2003 11:15:19 -0500


> Your solution for itertools can work with map too:
> 
> def repeat(v,n):
>     while n:
>        yield v
>        n-=1
> 
> map(f,L,repeat(K,len(L))) 

The itertools combine together so you can do it all 
at C speed and not have to create your own ad-hoc
generator:

from itertools import repeat, islice
map(f, L, islice(repeat(K),len(L)))


Raymond Hettinger