[Python-Dev] TypeError: f() missing 1 required positional argument: 'x'

Guido van Rossum guido at python.org
Thu Sep 20 17:52:47 CEST 2012


On Thu, Sep 20, 2012 at 7:12 AM, Benjamin Peterson <benjamin at python.org> wrote:
> 2012/9/20 Mark Dickinson <dickinsm at gmail.com>:
>> Thoughts?
>
> I tried to define the error messages in terms of the callee's
> signature. I call the formals that are not variadic, keyword variadic,
> or keyword-only, positional. For example, in
>
> def f(a, b, c, *args, d):
>      pass
>
> a, b, and c are positional. Hence the "positional" in error messages.

No -- Mark's point is that (even given this syntax) you *could* pass
them using keywords.

I think Brett's got it right and we should just refer to a and b as
'arguments'. For d, we should use keyword arguments (or, in full,
keyword-only arguments). That's enough of a distinction.

Of course, in a specific call, we can continue to refer to positional
and keyword arguments based on the actual syntax used in the call.

Maybe this is also a good time to start distinguishing between
arguments (what you pass, call syntax) and parameters (what the
function receives, function definition syntax)?

> 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).
>
> I'm certainly open to suggestions.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list