Incorrect number of arguments
Steven D'Aprano
steve at REMOVEMEcyber.com.au
Thu Jun 9 01:21:21 EDT 2005
Steven D'Aprano wrote:
> I worked around this problem by predicting what error message to expect
> given N expected arguments and M supplied arguments. Yuck: this is a
> messy, inelegant, ugly hack :-( Thank goodness that functions are first
> class objects that support introspection :-)
*eureka moment*
I can use introspection on the function directly to see
how many arguments it accepts, instead of actually
calling the function and trapping the exception.
> So, I'm wondering if there is a good reason why TypeError is generated
> instead of (say) ArgumentError, or if it is just a wart of the language
> for historical reasons?
Still a good question though. Why is it TypeError?
--
Steven.
More information about the Python-list
mailing list