[Python-ideas] Showing qualified names when a function call fails

Neil Girdhar mistersheik at gmail.com
Tue Oct 25 03:19:57 EDT 2016


I was thinking of posting something like the first suggestion myself.  Both 
would be a great additions.

On Monday, October 24, 2016 at 6:10:52 PM UTC-4, Ryan Gonzalez wrote:
>
> I personally find it kind of annoying when you have code like this:
>
>
> x = A(1, B(2, 3))
>
>
> and Python's error message looks like this:
>
>
> TypeError: __init__() takes 1 positional argument but 2 were given
>
>
> It doesn't give much of a clue to which `__init__` is being called. At all.
>
> The idea: when showing the function name in an error like this, show the 
> fully qualified name, like:
>
>
> TypeError: A.__init__() takes 1 positional argument but 2 were given
>
>
> This would be MUCH more helpful!
>
>
> Another related change would be to do the same thing in tracebacks:
>
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<stdin>", line 2, in __init__
> AssertionError
>
>
> to:
>
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<stdin>", line 2, in MyClass.__init__
> AssertionError
>
>
> which could make it easier to find where exactly an error originated.
>
> -- 
> Ryan (ライアン)
> [ERROR]: Your autotools build scripts are 200 lines longer than your 
> program. Something’s wrong.
> http://kirbyfan64.github.io/
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161025/526ec43b/attachment.html>


More information about the Python-ideas mailing list