New submission from metaxm <met...@gmail.com>:

>>> 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?

----------
components: Interpreter Core
messages: 326945
nosy: metaxm
priority: normal
severity: normal
status: open
title: f(a=1, *args) should be a SyntaxError
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to