diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-03-30 21:21:24 +0100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-03-30 21:21:24 +0100 |
| commit | 230fec77d7bd9bae5e86a009d549550d6047fd07 (patch) | |
| tree | 2620e7898155d2973153fba69cab5aab0ace54d0 /tests/basics/fun-callstardblstar.py | |
| parent | f6a820903afe12760b27553831c3bdb16c50b985 (diff) | |
py: Implement positional and keyword args via * and **.
Extends previous implementation with * for function calls to * and **
for both function and method calls.
Diffstat (limited to 'tests/basics/fun-callstardblstar.py')
| -rw-r--r-- | tests/basics/fun-callstardblstar.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/basics/fun-callstardblstar.py b/tests/basics/fun-callstardblstar.py new file mode 100644 index 000000000..f2fd29107 --- /dev/null +++ b/tests/basics/fun-callstardblstar.py @@ -0,0 +1,17 @@ +# test calling a function with *tuple and **dict + +def f(a, b, c, d): + print(a, b, c, d) + +f(*(1, 2), **{'c':3, 'd':4}) +f(*(1, 2), **{['c', 'd'][i]:(3 + i) for i in range(2)}) + +# test calling a method with *tuple and **dict + +class A: + def f(self, a, b, c, d): + print(a, b, c, d) + +a = A() +a.f(*(1, 2), **{'c':3, 'd':4}) +a.f(*(1, 2), **{['c', 'd'][i]:(3 + i) for i in range(2)}) |
