Message326945
>>> def f(a, b, c):
... pass
>>> f(a=1, 2, 3)
SyntaxError: positional argument follows keyword argument
>>> f(a=1, *(2, 3))
TypeError: f() got multiple values for argument 'a'
f(a=1, 2, 3) will cause a SyntaxError, but f(a=1, *(2, 3)) will cause a TypeError. This makes me feel confused.
As keyword arguments must follow positional arguments, I suppose a SyntaxError rather than a TypeError should be reported if a variadic argument follows keyword arguments. Would you kindly explain why the CPython takes different actions for these two cases? |
|
Date |
User |
Action |
Args |
2018-10-03 08:01:12 | metaxm | set | recipients:
+ metaxm |
2018-10-03 08:01:12 | metaxm | set | messageid: <1538553672.9.0.545547206417.issue34882@psf.upfronthosting.co.za> |
2018-10-03 08:01:12 | metaxm | link | issue34882 messages |
2018-10-03 08:01:12 | metaxm | create | |
|