Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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)

# Output
# 1, 0, 1

myfunc(**dict_vec)

# Output
# 1, 0, 1
 
PREVIOUS NEXT
Tagged: #Function #argument #unpacking #python
ADD COMMENT
Topic
Name
9+2 =