1cdef sorteditems(d):
2    l = list(d.items())
3    l.sort()
4    return tuple(l)
5
6def spam(x, y, z):
7    """
8    >>> spam(1,2,3)
9    (1, 2, 3)
10    >>> spam(1,2)
11    Traceback (most recent call last):
12    TypeError: spam() takes exactly 3 positional arguments (2 given)
13    >>> spam(1,2,3,4)
14    Traceback (most recent call last):
15    TypeError: spam() takes exactly 3 positional arguments (4 given)
16    >>> spam(1,2,3, a=1)
17    Traceback (most recent call last):
18    TypeError: spam() got an unexpected keyword argument 'a'
19    """
20    return (x, y, z)
21
22def grail(x, y, z, *a):
23    """
24    >>> grail(1,2,3)
25    (1, 2, 3, ())
26    >>> grail(1,2,3,4)
27    (1, 2, 3, (4,))
28    >>> grail(1,2,3,4,5,6,7,8,9)
29    (1, 2, 3, (4, 5, 6, 7, 8, 9))
30    >>> grail(1,2)
31    Traceback (most recent call last):
32    TypeError: grail() takes at least 3 positional arguments (2 given)
33    >>> grail(1,2,3, a=1)
34    Traceback (most recent call last):
35    TypeError: grail() got an unexpected keyword argument 'a'
36    """
37    return (x, y, z, a)
38
39def swallow(x, y, z, **k):
40    """
41    >>> swallow(1,2,3)
42    (1, 2, 3, ())
43    >>> swallow(1,2,3,4)
44    Traceback (most recent call last):
45    TypeError: swallow() takes exactly 3 positional arguments (4 given)
46    >>> swallow(1,2,3, a=1, b=2)
47    (1, 2, 3, (('a', 1), ('b', 2)))
48    >>> swallow(1,2,3, x=1)
49    Traceback (most recent call last):
50    TypeError: swallow() got multiple values for keyword argument 'x'
51    """
52    return (x, y, z, sorteditems(k))
53
54def creosote(x, y, z, *a, **k):
55    """
56    >>> creosote(1,2,3)
57    (1, 2, 3, (), ())
58    >>> creosote(1,2,3,4)
59    (1, 2, 3, (4,), ())
60    >>> creosote(1,2,3, a=1)
61    (1, 2, 3, (), (('a', 1),))
62    >>> creosote(1,2,3,4, a=1, b=2)
63    (1, 2, 3, (4,), (('a', 1), ('b', 2)))
64    >>> creosote(1,2,3,4, x=1)
65    Traceback (most recent call last):
66    TypeError: creosote() got multiple values for keyword argument 'x'
67    """
68    return (x, y, z, a, sorteditems(k))
69
70def onlyt(*a):
71    """
72    >>> onlyt(1)
73    (1,)
74    >>> onlyt(1,2)
75    (1, 2)
76    >>> onlyt(a=1)
77    Traceback (most recent call last):
78    TypeError: onlyt() got an unexpected keyword argument 'a'
79    >>> onlyt(1, a=2)
80    Traceback (most recent call last):
81    TypeError: onlyt() got an unexpected keyword argument 'a'
82    """
83    return a
84
85def onlyk(**k):
86    """
87    >>> onlyk(a=1)
88    (('a', 1),)
89    >>> onlyk(a=1, b=2)
90    (('a', 1), ('b', 2))
91    >>> onlyk(1)
92    Traceback (most recent call last):
93    TypeError: onlyk() takes exactly 0 positional arguments (1 given)
94    >>> onlyk(1, 2)
95    Traceback (most recent call last):
96    TypeError: onlyk() takes exactly 0 positional arguments (2 given)
97    >>> onlyk(1, a=1, b=2)
98    Traceback (most recent call last):
99    TypeError: onlyk() takes exactly 0 positional arguments (1 given)
100    """
101    return sorteditems(k)
102
103def tk(*a, **k):
104    """
105    >>> tk(a=1)
106    (('a', 1),)
107    >>> tk(a=1, b=2)
108    (('a', 1), ('b', 2))
109    >>> tk(1)
110    (1,)
111    >>> tk(1, 2)
112    (1, 2)
113    >>> tk(1, a=1, b=2)
114    (1, ('a', 1), ('b', 2))
115    """
116    return a + sorteditems(k)
117