map

Wolfgang Strobl news3 at mystrobl.de
Mon Aug 31 01:34:28 EDT 2009


elsa <kerensaelise at hotmail.com>:

>now, say I want to map myFunc onto myList, with always the same
>argument for b, but iterating over a:

>>> from functools import partial
>>> def g(x,y=1): return x+y
...
>>> map(partial(g,y=2),[1,2])
[3, 4]
>>> map(partial(g,y=42),[1,2])
[43, 44]


-- 
Wir danken für die Beachtung aller Sicherheitsbestimmungen



More information about the Python-list mailing list