Arbitrary number of arguments passing a tuple
examples/functions/sum_of_tuple.py
from mysum import mysum z = (2, 3, 5, 6) mysum(z)
((2, 3, 5, 6),) <class 'tuple'> Traceback (most recent call last): File "/home/gabor/work/slides/python/examples/functions/sum_of_tuple.py", line 5, in <module> mysum(z) File "/home/gabor/work/slides/python/examples/functions/mysum.py", line 6, in mysum total += s TypeError: unsupported operand type(s) for +=: 'int' and 'tuple'
examples/functions/sum_of_tuple_fixed.py
from mysum import mysum z = (2, 3, 5, 6) print(mysum(*z))
(2, 3, 5, 6) <class 'tuple'> 16