code.put('case %2d: ' % (i+1))
item = "PyTuple_GET_ITEM(%s, %d)" % (Naming.args_cname, i)
self.generate_arg_assignment(arg, item, code)
+ if min_positional_args == 0:
+ code.put('case 0: ')
+ code.putln('break;')
if self.star_arg:
if min_positional_args:
- code.putln('break;')
for i in range(min_positional_args-1, -1, -1):
code.putln('case %2d:' % i)
code.put_goto(argtuple_error_label)
else:
- if min_positional_args == 0:
- code.put('case 0: ')
- code.putln('break;')
code.put('default: ')
code.put_goto(argtuple_error_label)
code.putln('}')
1 2 0 1
>>> d(1,2,3, key=None)
1 2 1 1
-
+
+ >>> c()
+ 10 20 0
+ >>> c(1)
+ 1 20 0
+ >>> c(1,2)
+ 1 2 0
+ >>> c(key=None)
+ 10 20 1
+ >>> c(1, key=None)
+ 1 20 1
+ >>> c(1,2, key=None)
+ 1 2 1
+
"""
+def c(a=10, b=20, **kwds):
+ print a, b, len(kwds)
+
def d(a, b=1, *args, **kwds):
print a, b, len(args), len(kwds)