diff options
Diffstat (limited to 'tests/basics/fun_callstar.py')
-rw-r--r-- | tests/basics/fun_callstar.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/basics/fun_callstar.py b/tests/basics/fun_callstar.py new file mode 100644 index 0000000000..255563b26b --- /dev/null +++ b/tests/basics/fun_callstar.py @@ -0,0 +1,33 @@ +# function calls with *pos + +def foo(a, b, c): + print(a, b, c) + +foo(*(1, 2, 3)) +foo(1, *(2, 3)) +foo(1, 2, *(3,)) +foo(1, 2, 3, *()) + +# Another sequence type +foo(1, 2, *[100]) + +# Iterator +foo(*range(3)) + +# method calls with *pos + +class A: + def foo(self, a, b, c): + print(a, b, c) + +a = A() +a.foo(*(1, 2, 3)) +a.foo(1, *(2, 3)) +a.foo(1, 2, *(3,)) +a.foo(1, 2, 3, *()) + +# Another sequence type +a.foo(1, 2, *[100]) + +# Iterator +a.foo(*range(3)) |