Say I have a function:
def omni(self, func, *args, **kwargs):
that always calls func
.
However, func's parameters can be any combination of things. For example
def func(self):
# omni should only pass in self
def func():
# omni should pass in nothing
def func(foo, key='foo'):
# omni should pass in a foo param and a key if supplied one
def func(*args, **kwargs):
# omni should pass in everything
Is there any way to pass into func
from omni
only the necessary parameters? i.e. is the above possible?
ex.
def foo(m):
pass
obj.omni(foo, m, a=1)
# this should call
foo(m)
def foo(self, **kwargs):
pass
obj.omni(foo, m, 1, b=2)
# this should call
foo(self, b=2)