First page Back Continue Last page Overview Image

** in Funktionsaufrufen

Das folgende Beispiel zeigt die Benutzung von ** in einem Funktionsaufruf:

>>> 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')

Und nun die Kombination mit *:

>>> t = (47,11)

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

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

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

>>>