fun_callstardblstar.py 388 B

1234567891011121314151617
  1. # test calling a function with *tuple and **dict
  2. def f(a, b, c, d):
  3. print(a, b, c, d)
  4. f(*(1, 2), **{'c':3, 'd':4})
  5. f(*(1, 2), **{['c', 'd'][i]:(3 + i) for i in range(2)})
  6. # test calling a method with *tuple and **dict
  7. class A:
  8. def f(self, a, b, c, d):
  9. print(a, b, c, d)
  10. a = A()
  11. a.f(*(1, 2), **{'c':3, 'd':4})
  12. a.f(*(1, 2), **{['c', 'd'][i]:(3 + i) for i in range(2)})