"Andrew Dalke" <ad****@mindspring.com> wrote in message
news:b6***************@newsread3.news.pas.earthlin k.net...
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?
This raises another (newbie) question that I had.
Take a trivial example:
from operator import truth
bool1 = lambda lst: map(truth, lst)
def bool2(lst): return map(truth,lst)
def bool3(lst): return [truth(_) for _ in lst]
To my eyes, the most natural is bool2.
I would never have considered bool1 if
I had not come across it in the Merz book,
but it is both shortest and clear.
I include bool3 just for comparison: I think
the way in which it is harder to read illustrates
the usefulness of 'map'.
So, are there any obvious considerations when
making a choice among these. In particular,
why might someone prefer the style in bool1?
Thanks,
Alan Isaac