replay 'apply' with extended call

Andrew Dalke adalke at mindspring.com
Mon Oct 25 02:32:39 EDT 2004


Alan G Isaac wrote:
> apply_each = lambda fns, args=[]: map(apply, fns, [args]*len(fns))

> What is the equivalent with extended call syntax?

How about a solution which replaces the 'map' with a
list comprehension?

def apply_each(fns, args = []):
   return [fn(*args) for fn in fns]

Conversion to lambda form is trivial for this case but I
figured if you're going to name it, why use a lambda?


				Andrew
				dalke at dalkescientific.com



More information about the Python-list mailing list