First page Back Continue Last page Overview Graphics

* in Function Calls

A * can appear in function calls as well:

The semantics is in this case “inverse” to a star in a function definition. An argument will be unpacked and not packed:

>>> def f(x,y,z):

... print(x,y,z)

...

>>> p = (47,11,12)

>>> f(*p)

(47, 11, 12)

This call is definitely more comfortable than the following one:

>>> f(p[0],p[1],p[2])

(47, 11, 12)

>>>