[Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method (original) (raw)
Stephen J. Turnbull stephen at xemacs.org
Thu May 20 04:55:02 CEST 2010
- Previous message: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method
- Next message: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Giampaolo RodolĂ writes:
class A: ... def echo(self, x): ... return x ... a = A() a.echo() Traceback (most recent call last): File "", line 1, in TypeError: echo() takes exactly 2 arguments (1 given)
I bet my last 2 cents this has already been raised in past but I want to give it a try and revamp the subject anyway. Is there a reason why the error shouldn't be adjusted to state that 1 argument is actually required instead of 2?
As a function, it does take two arguments, and can be called explicitly that way, no? Adjustment is not enough, the message needs to be substantially rewritten. Something like
TypeError: invoked as a method, echo() takes exactly 1 argument (0 given)
captures the semantics, but is perhaps too verbose.
- Previous message: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method
- Next message: [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]