3 ms·
"The one place they are pretty convenient is in languages (like Python) where multiple return values from one function can be used as multiple input parameters
by falcolas 13y ago
"The one place they are pretty convenient is in languages (like Python) where multiple return values from one function can be used as multiple input parameters to another."
Python only returns a single value - a tuple. It's just that there is symantic sugar on the functions side to fold multiple values into a tuple, and on the side that's returned to, it's simple value unpacking.
You can validate this in the following way:
>>> def foo():
... return 1, 2
>>> x = foo()
>>> isinstance(x, tuple)
True
The unpacking of tuples into arguments is simply more syntactic sugar, if very useful syntactic sugar.
In short, while I love Python, it's still returning just a single value - a tuple, that gives the appearance of returning multiple values.