I have a function which is
def abc(a,b,c):
#do something
pass
I would like to call this with a list instead of abc(a,b,c)
, e.g.:
abc([1,2,3])
I cannot change the definition of abc
.
Use case:
I am trying to write my own eval using the ast
library
While implementing the ast.Call
, I would like to be able to call my functions with multiple arguments.
However, if node is of type ast.Call
, the arguments are passed in the form of a list.
E.g.:
>> exp = ast.parse('abc(1,2)', mode='eval').body
>> exp
# <_ast.Call at 0x2ab3c5bef7d0>
>> exp.args
#[<_ast.Num at 0x2ab3c5bef850>, <_ast.Num at 0x2ab3c5bef890>]
The problem is, I cannot understand how to call a function whose name is abc
when the args returned to me is a list.
I would be trying to call library functions like min
, max
, len
, str
and my own functions like contains
, get_item
etc. What I can't understand is, how do I pass a list of arguments to a function that takes multiple arguments?