K
kj
Suppose that f is an object whose type is 'function'.
Is there a way to find out f's list of formal arguments?
The reason for this is that I'm trying to write a decorator and
I'd like the wrapper to be able to check the number of arguments
passed. Specifically, I'd like the wrapper to look as shown below:
def _wrap(f):
def wrapper(self, *params):
n_expected = len(f.FORMAL_ARGS)
n_received = len(params)
if n_received is not n_expected:
raise RuntimeError("Wrong number of arguments passed "
"to %s" % f.__name__)
return self.send_jsonrpc_request(f.__name__, params)
return wrapper
....but I'm missing something like the hypothetical attribute
FORMAL_ARGS above.
TIA!
Kynn
Is there a way to find out f's list of formal arguments?
The reason for this is that I'm trying to write a decorator and
I'd like the wrapper to be able to check the number of arguments
passed. Specifically, I'd like the wrapper to look as shown below:
def _wrap(f):
def wrapper(self, *params):
n_expected = len(f.FORMAL_ARGS)
n_received = len(params)
if n_received is not n_expected:
raise RuntimeError("Wrong number of arguments passed "
"to %s" % f.__name__)
return self.send_jsonrpc_request(f.__name__, params)
return wrapper
....but I'm missing something like the hypothetical attribute
FORMAL_ARGS above.
TIA!
Kynn