[Python-3000] Changing function-related TypeErrors

Greg Ewing greg.ewing at canterbury.ac.nz
Sun May 7 02:53:14 CEST 2006


Collin Winter wrote:
> Do you change
> function X to match the call site or write a function with the proper
> signature that wraps function X? Of course not. You change the call
> site to match the signature.

Or to put it another way, calling this a TypeError assumes
that you were mistaken about which function to call. But
it's just as likely (probably more likely) that you have
the right function but the wrong arguments.

So I think it makes the most sense to have a new exception
such as ArgumentError for this. It says what is wrong
without making assumptions about how it came to be that
way. Subclass it from TypeError if you want backwards
compatibility.

--
Greg


More information about the Python-3000 mailing list