0

I have a function and I have an array of arguments that I want to pass to the function when calling it like this:

def function(arg):
    pass

function(arg)#call

but I want:

target = function
args = list()
output = call(function,args)

I know, that I can do it with Thread, but I want get a return to main Thread

Thread(target=target,args=args).start() # without output :(

The only possible solution I have come up with is

output = exec('function_name('+','.join(args))

P.S. The functions that I call have a variable number of positional and optional arguments

P.P.S. I can't edit function's code

martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

1

If those are positional arguments you can use function(*args).

bruno-uy
  • 1,647
  • 12
  • 20