First page Back Continue Last page Overview Graphics

** in Function Calls

The following example demonstrates the usage of ** in a

function call:

>>> def f(a,b,x,y):

... print(a,b,x,y)

>>> d = {'a':'append', 'b':'block','x':'extract','y':'yes'}

>>> f(**d)

('append', 'block', 'extract', 'yes')

And now in combination with *:

>>> t = (47,11)

>>> d = {'x':'extract','y':'yes'}

>>> f(*t, **d)

(47, 11, 'extract', 'yes')

>>>