[Python-Dev] TypeError: f() missing 1 required positional argument: 'x'
steve at pearwood.info
Thu Sep 20 22:21:54 CEST 2012
On 21/09/12 05:45, Ethan Furman wrote:
>> I don't expect error messages to give a complete catalog of every
>> problem with a specific function call. If f() reports that required
>> argument 'a' is missing, that does not imply that no other required
>> arguments are also missing. I think it is perfectly acceptable to
>> not report the missing 'b' until the missing 'a' is resolved.
> I disagree. There is no reason (that I'm aware of ;) that the missing
>'b' cannot be noticed and reported at the same time as the missing 'a'.
Listing every missing argument does not scale well as the number of
def f(spam, ham, cheese, aardvark, halibut, *, shrubbery, parrot, wafer_thin_mint):
I would be -0 on an error message like:
TypeError: f() needs arguments 'spam', 'ham', 'cheese', 'aardvark', 'halibut' and keyword-only arguments 'shrubbery', 'parrot', 'wafer_thin_mint'
but wouldn't strongly object. I think it is acceptable (although not
ideal) if calling f() only reported the first missing argument it
But I do think that we should not make any language guarantees about
error messages being "complete" or not.
More information about the Python-Dev