[Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method (original) (raw)
Terry Reedy tjreedy at udel.edu
Thu May 20 18:55:13 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 ]
On 5/20/2010 4:02 AM, Floris Bruynooghe wrote:
TypeError: invoked as a method, echo() takes exactly 1 argument (0 given)
captures the semantics, but is perhaps too verbose. How about: TypeError: bound method echo() takes exactly 1 argument (0 given) That way you can also have: "unbound method echo() ...". And it's as semantically correct as the short "echo() takes ..." Not having looked at the code I don't know how hard it is for the code that raises this traceback to notice if it's a bound or unbound method tough.
In 3.x, there are no unbound method objects, just functions. But that should make the difference easier to detect, as bound/unbound method objects were actually the same class, differing only in an attribute.
I notice
list.append() Traceback (most recent call last): File "<pyshell#0>", line 1, in list.append() TypeError: descriptor 'append' of 'list' object needs an argument
So here the message is specific to the type of the callable.
- 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 ]