[Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

Greg Ewing greg.ewing at canterbury.ac.nz
Fri May 21 02:53:16 CEST 2010


Ben Finney wrote:

>>Something like "1 argument in addition to 'self'" would be reasonably
>>clear and would cover both situations.
> 
> Except that there's nothing special to the syntax or parser about the
> name ‘self’.

That's true, but the use of the word 'self' here isn't meant
to refer to the name of a parameter. The message is aimed at
the caller of the function, who doesn't necessarily know or
care what the parameter is actually called.

The important thing is that it represents the object the method
is being called for, and 'self' is the traditional term used
when talking about that. I can't think of anything that would
be more accurate without being excessively verbose or pedantic.

-- 
Greg


More information about the Python-Dev mailing list