Just a single method or support args/kwargs?
Syntax: Select all
def myapifunc(callback):
callback()
vs
Syntax: Select all
def myapifunc(callback, callback_args=(), callback_kwargs={}):
callback(*callback_args, **callback_kwargs)
Please note that with both solutions you can use arguments, except you need a wrapper for the first like this:
Syntax: Select all
class Wrap(object):
def __init__(self, callback, args, kwargs):
self.callback = callback
self.args = args
self.kwargs = kwargs
def __call__(self):
self.callback(*self.args, **self.kwargs)