I have the following code to use * argument for a function.
inputs = [fill(input) for input in input_shapes]
# num_runs is an integer
def bench(num_runs):
inputs.append(num_runs) # can I remove this?
handle_type(*inputs)
del inputs[-1] # can I remove this?
I want to know a better way to handle *inputs
, so I don't have to call append
and del
every time.
I tried a simple example:
inputs = [1, 2, 3]
inputs2 = [1, 2]
def Test(a, b, c):
print (a, b, c)
Test(*inputs) # works
Test(*inputs2, 3) # SyntaxError: only named arguments may follow *expression
I found a solution here Unpacking arguments: only named arguments may follow *expression and it is what I am looking for.