Parallel Python: What is a callback?

后端 未结 5 1546
别跟我提以往
别跟我提以往 2020-12-04 07:27

In Parallel Python it has something in the submit function called a callback (documentation) however it doesn\'t seem to explain it too well. I\'ve posted on

5条回答
  •  孤城傲影
    2020-12-04 08:00

    A callback is simply a function. In Python, functions are just more objects, and so the name of a function can be used as a variable, like so:

    def func():
        ...
    
    something(func)
    

    Note that many functions which accept a callback as an argument usually require that the callback accept certain arguments. In this case, the callback function will need to accept a list of arguments specified in callbackargs. I'm not familiar with Parallel Python so I don't know exactly what it wants.

提交回复
热议问题