On Wed, Mar 04, 2020 at 02:09:00PM +0200, Serhiy Storchaka wrote:

> If add such exception, ArgumentError looks more appropriate name.

Thanks Serhiy, I considered that but thought that ArgumentError was 
likely to be used in third-party libraries.

A quick google shows that argparse and Boost both have an ArgumentError 
exception.


[...]
> The way to get such error is when the caller does not know what function 
> it calls. For example,
> 
>     functools.reduce(len, [1, 2])
>     sorted([1, 2], key=divmod)
> 
> Authors of reduce() and sorted() do not know what function they call, it 
> is passed as an argument. The error is on the side of the user of these 
> function, it is passing a wrong *type* of the function. It is definitely 
> a TypeError.

That might be so, and I am not debating whether the error is really a 
TypeError or not. Backwards compatibility means that it must stay 
TypeError, or a subclass of TypeError.

I had not thought of reduce(), map(), sorted() etc, that's another good 
use-case, thank you!



-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/VHZLMDD7HG7QVIHNABWWVVTOWZZDLNOJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to