python
Function argument unpacking in Python
def myfunc(x, y, z):
print(x, y, z)
tuple_vec = (1, 0, 1)
dict_vec = {'x': 1, 'y': 0, 'z': 1}
>>> myfunc(*tuple_vec)
1, 0, 1
>>> myfunc(**dict_vec)
1, 0, 1
Was this helpful?
Similar Posts
- [Python] Default value of function argument
- [Python] Range - standard function to create a list of numbers
- [Python] Function returns multiple values
- [Python] Function parameters - pack and unpack
- [Python] Eval() function
- [Python] Get nodeid, module, function name using Pytest request built-in fixture
- [Python] Using inspect.stack() to get module name, path, function name