On Wed, Aug 10, 2011, Chris Weisiger wrote:
>
> There's probably a more generic mailing list I could send this to, but
> I'm on too many lists as it is...hope y'all don't mind.
>
> Anyway, I often find myself in the situation of "I have a list of
> objects. I want to make a corresponding list of functions that operate
> on those objects". So I write up something like this:
>
> funcList = []
> for item in objectList:
> funcList.append(lambda input: item.actOn(input))
Why can't you do:
for item in object_list:
func_list.append(item.act_on)
(Notice who I change the names to match PEP8.)
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/
"If you don't know what your program is supposed to do, you'd better not
start writing it." --Dijkstra
_______________________________________________
Pythonmac-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG