[Python-Dev] TypeError: f() missing 1 required positional argument: 'x'
chris.jerdonek at gmail.com
Thu Sep 20 16:43:34 CEST 2012
On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson <benjamin at python.org> wrote:
> def f(a, b, c, *args, d):
> a, b, and c are positional. Hence the "positional" in error messages.
> As you noted in your next message, keyword-only arguments need to be
> distinguished from these "positional" arguments somehow. Maybe it
> helps to think of "positional" to mean "the only formals you can pass
> to with position" (excepting variadic ones).
That is how I think of "positional".
However, the other wrinkle is that some arguments really are
"position-only," for example:
Traceback (most recent call last):
TypeError: len() takes no keyword arguments
I think it is a defect of our documentation that we don't have a way
to distinguish between "positional" and "position-only" arguments in
the function signature notation we use in our documentation, leading
to issues like this one:
"accept keyword arguments on most base type methods and builtins":
More information about the Python-Dev