このトピックに従う:ユーザーがAPI関数を「拡張」できるようにする
class Inspector:
def __init__(self, passedFunc):
self.passedFunc = passedFunc
def __call__(self, *args, **kwargs):
# Inspector needs to generate a list of arguments of the passed function and print them in *correct* order
# now how to generate a list of arguments using data from both ''args' and 'kwargs'?
# the user might keep default argument values, in which case both will be None,
# he might only use args, in which case it is easy,
# but he might also use kwargs, in which case I don't see how to generate a list with correct order of arguments
# and he might use all 3 from above together
# I found this solution for when only default arguments are used
if args == () and kwargs == {}: args = self.passedFunc.__defaults__
print args
@Inspector
def exampleFunc(value=0, otherValue=3):
pass
exampleFunc()
すべてのシナリオで正しい順序引数リストを生成するにはどうすればよいですか?