On Wed, 11 Jul 2012 08:41:57 +0200, Daniel Fetchinson wrote:

> funcs = [ lambda x: x**i for i in range( 5 ) ]

Here's another solution:

from functools import partial
funcs = [partial(lambda i, x: x**i, i) for i in range(5)]


Notice that the arguments i and x are defined in the opposite order. 
That's because partial only applies positional arguments from the left. 
If there was a "right partial" that applies from the right, we could use 
the built-in instead:

funcs = [rpartial(pow, i) for i in range(5)]



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to