Reputation: 13
In a nutshell, I'm trying to implement the following:
def function_one(value):
...
return a, b
def function_two(a, b):
...
And when I try
function_two(function_one(value))
I get an error message: "function_two() missing 1 required positional argument: 'b'"
Is there a way to make this work as intended? Thanks!
Upvotes: 1
Views: 57
Reputation: 318788
You have to unpack the tuple you return into separate arguments:
function_two(*function_one(value))
Another option would be changing function_two
to accept a single argument and then unpack it inside the function or use it as-is. Whether this is a good idea or not depends on the context.
Upvotes: 5