>>> def exampleArgs ( * argList ):
... return argList
...
>>> exampleArgs (1, 2, 3)
(1, 2, 3)
>>> def exampleArgs ( ** argList ):
... return argList
...
>>> exampleArgs (1, 2, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: exampleArgs() takes exactly 0 arguments (3 given)
>>> exampleArgs (a = 1, b = 2)
{'a': 1, 'b': 2}
>>> def exampleArgs (a, b, * argTuple, ** argDict ):
... yield a
... yield b
... yield argTuple
... yield argDict
...
>>> for returnValue in exampleArgs( "a", "b", 1, 2, 3, keyOne=1, keyTwo=2):
... print returnValue
...
a
b
(1, 2, 3)
{'keyOne': 1, 'keyTwo': 2}
>>> for returnValue in exampleArgs( "a", "b", 1, 2, 3, keyOne=1, keyTwo=2):
... print returnValue
...
a
b
(1, 2, 3)
{'keyOne': 1, 'keyTwo': 2}
>>> for returnValue in exampleArgs( "a", "b", 1, 2, 3, keyOne=1, keyOne=2):
... print returnValue
...
File "<stdin>", line 1
SyntaxError: keyword argument repeated
>>> def exampleArgs (a=1, b=2, * argTuple, ** argDict ):
... yield a
... yield b
... yield argTuple
... yield argDict
...
>>> for returnValue in exampleArgs():
... print returnValue
...
1
2
()
{}
>>> for returnValue in exampleArgs(c = 3):
... print returnValue
...
1
2
()
{'c': 3}
>>> for returnValue in exampleArgs(3):
... print returnValue
...
3
2
()
{}
>>> for returnValue in exampleArgs(a=1, b=2, 3):
... print returnValue
...
File "<stdin>", line 1
SyntaxError: non-keyword arg after keyword arg
>>> for returnValue in exampleArgs(1, 2, 3):
... print returnValue
...
1
2
(3,)
{}
>>> for returnValue in exampleArgs(3,):
... print returnValue
...
3
2
()
{}
>>> for returnValue in exampleArgs((3,)):
... print returnValue
...
(3,)
2
()
{}