Is there a way to expand a Python tuple into a function - as actual parameters?
For example, here
expand() does the magic:
tuple = (1, "foo", "bar") def myfun(number, str1, str2): return (number * 2, str1 + str2, str2 + str1) myfun(expand(tuple)) # (2, "foobar", "barfoo")
I know one could define
myfun((a, b, c)), but of course there may be legacy code.
myfun(*tuple) does exactly what you request.
Side issue: don't use as your identifiers builtin type names such as
set, and so forth -- it's horrible practice and it will come back and bite you when you least expect it,
so just get into the habit of actively avoiding hiding builtin names with your own identifiers.
Note that you can also expand part of argument list:
myfun(1, *("foo", "bar"))