[Python-ideas] BindError as a built-in TypeError subclass (on the margin of PEP 362 discussion)

Chris Rebert pyideas at rebertia.com
Mon Jun 11 03:12:36 CEST 2012


On Sun, Jun 10, 2012 at 5:00 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> Chris Rebert wrote:
>
>>> Since this will be an error that beginners see (frequently), I suggest
>>> ArgumentError is more friendly than BindError.
>>
>> I note that Ruby also has an ArgumentError, which it raises both for
>> calls with an incorrect number of arguments and in cases when Python
>> would raise ValueError.
>
> Even if I wanted to replace ValueError with ArgumentError (and I don't), we
> couldn't due to backward compatibility.
>
> (Although I suppose ArgumentError could inherit from both TypeError and
> ValueError.)
>
> My concept is that errors due to the wrong argument count, duplicate or
> missing keyword arguments, etc. which currently raise TypeError could raise
> ArgumentError, a subclass, instead.
>
> That will make distinguishing between "passed the wrong number of arguments"
> from "passed the wrong type of argument" easier.

You seem to have misinterpreted the intent behind my post. I'm in no
way arguing that ValueError and "ArgumentBindingError" should be
conflated. I'm pointing out that another very similar language (Ruby)
has an error of the same name with a very similar purpose (which it
also distinguishes from its TypeError), thus providing further
validation of the use case for the proposed ArgumentBindingError.

Cheers,
Chris



More information about the Python-ideas mailing list