Python map list item to function with arguments

前端 未结 4 2052
我寻月下人不归
我寻月下人不归 2020-12-04 16:40

Is there any way to map list items to a function along with arguments. I have a list:

pages = [p1, p2, p3, p4, p5...]

And I have to call fu

4条回答
  •  抹茶落季
    2020-12-04 17:15

    You could use a list comprehension

    [myFunc(p, additionalArgument) for p in pages]
    

    or functools.partial()

    map(functools.partial(myFunc, some_arg=additionalArgument), pages)
    

提交回复
热议问题