A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-May/100216.html below:

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

[Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method [Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a methodTerry Reedy tjreedy at udel.edu
Thu May 20 18:55:13 CEST 2010
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 <module>
     list.append()
TypeError: descriptor 'append' of 'list' object needs an argument

So here the message is specific to the type of the callable.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4