Parallel mapping functions in IPython w/ multiple parameters

后端 未结 5 1010
闹比i
闹比i 2021-01-30 21:05

I\'m trying to use IPython\'s parallel environment and so far, it\'s looking great but I\'m running into a problem. Lets say that I have a function, defined in a library

<
5条回答
  •  萌比男神i
    2021-01-30 21:44

    An elegant way to do this is with partial functions.

    If you know that you want the first argument of foo to be myArg, you can create a new function bar by

    from functools import partial
    bar = partial(foo, myARg)
    

    bar(otherArg) will then return foo(myArg,otherArg)

提交回复
热议问题