A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-September/121790.html below:

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

[Python-Dev] TypeError: f() missing 1 required positional argument: 'x'Steven D'Aprano 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
arguments increases.

def f(spam, ham, cheese, aardvark, halibut, *,  shrubbery, parrot, wafer_thin_mint):
     pass

f()

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
noticed.

But I do think that we should not make any language guarantees about
error messages being "complete" or not.


-- 
Steven
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4