summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/fun_calldblstar4.py
blob: acb332a8c23bb767f024bef1da7038bad1cedb74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# test calling a function with multiple **args


def f(a, b=None, c=None):
    print(a, b, c)


f(**{"a": 1}, **{"b": 2})
f(**{"a": 1}, **{"b": 2}, c=3)
f(**{"a": 1}, b=2, **{"c": 3})

try:
    f(1, **{"b": 2}, **{"b": 3})
except TypeError:
    print("TypeError")

# test calling a method with multiple **args


class A:
    def f(self, a, b=None, c=None):
        print(a, b, c)


a = A()
a.f(**{"a": 1}, **{"b": 2})
a.f(**{"a": 1}, **{"b": 2}, c=3)
a.f(**{"a": 1}, b=2, **{"c": 3})

try:
    a.f(1, **{"b": 2}, **{"b": 3})
except TypeError:
    print("TypeError")