Member predicate CallableValue::getArgumentForCall
Gets the argument in call corresponding to the n’th positional parameter of this callable.
Use this method instead of call.getArg(n) to handle the fact that this function might be used as
a bound-method, such that argument n of the call corresponds to the n+1 parameter of the callable.
This method also gives results when the argument is passed as a keyword argument in call, as long
as this is not a builtin function or a builtin method.
Examples:
-
if
thisrepresents thePythonFunctionValuefordef func(a, b):, andcallrepresentsfunc(10, 20), thengetArgumentForCall(call, 0)will give theControlFlowNodefor10. -
with
callrepresentingfunc(b=20, a=10),getArgumentForCall(call, 0)will give theControlFlowNodefor10. -
if
thisrepresents thePythonFunctionValuefordef func(self, a, b):, andcallrepresentsfoo.func(10, 20), thengetArgumentForCall(call, 1)will give theControlFlowNodefor10. Note: There will also exist aBoundMethodValue bmwherebm.getArgumentForCall(call, 0)will give theControlFlowNodefor10(notice the shift in index used).
ControlFlowNode getArgumentForCall(CallNode call, int n)