map

Paul Rubin http
Mon Aug 31 11:46:42 EDT 2009


elsa <kerensaelise at hotmail.com> writes:
> map(myFunc(b='booHoo'), myList)
> 
> Why doesn't this work? is there a way to make it work?

You can use functools.partial but a listcomp might be simpler:

   list(myfunc(a, b='booHoo') for a in myList)

There is another listcomp syntax with square brackets, but I try to
avoid it because it has broken behavior (leaks the index variable) in
Python 2.x.



More information about the Python-list mailing list