New submission from Ram Rachum:
When programming, I just got this exception:
builtins.TypeError: my_func() takes 1 positional argument but 2 were given
After a couple of minutes of investigation I figured out that the problem is
that the function has a `*` in its signature, so arguments must be specified as
keyword arguments, not positional arguments.
It would be nice if the exception message would include some text to suggest
that, like:
builtins.TypeError: my_func() takes 1 positional argument but 2 were given.
If you were trying to use the keyword-only argument foo, please specify it as
foo=value.
It's a little verbose and specific, but maybe it'll help people figure out this
problem, especially newbies. We can have logic to show this message only if
there are keyword-only arguments.
----------
components: Interpreter Core
messages: 229521
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Add suggestion about keyword arguments to this error message:
"builtins.TypeError: my_func() takes 1 positional argument but 2 were given"
versions: Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22652>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com