Applying map for partial argument
functional-programming, python
Solution
First of all, there is no need to use lambda AND partial - they are alternatives:
map(lambda x:f(x,fixed),srclist)
Secondly, you could just bind the second argument with `partial`, as long as you know the argument's name:
map(functools.partial(f,y=fixed),srclist)
Alternatively, use a list comprehension:
[f(x, fixed) for x in srclist]
Problem
Given the following function f with two arguments, what is the standard way to apply map to only x? ``` def f (x,y): print x,y ``` More specifically, I would like to perform the following operation with map in one line. ``` list=[1,2,3] fixed=10 for s in list: f(s,fixed) ``` One way to do so is: ``` import functools map(functools.partial(lambda x,y:f(y,x),fixed),list) ``` What is a better way?