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

Ryan Gonzalez rymg19 at gmail.com
Tue Oct 25 21:34:12 EDT 2016


Yeah, I just checked the source and tried changing it. Seems to work well.

On Tue, Oct 25, 2016 at 8:11 PM, Steven D'Aprano <steve at pearwood.info>
wrote:

> On Tue, Oct 25, 2016 at 04:55:21PM -0500, Ryan Gonzalez wrote:
> > Also, as an extension of this idea, would it be possible to improve
> errors
> > like this:
> >
> >
> > class X: pass
> > X() # object() takes no parameters
> >
> >
> > to show the actual type instead of just 'object'?
>
> My wild guess is that the cause is that __new__ looks like this:
>
> class object():
>     def __new__(cls, *args):
>         if args:
>              raise TypeError('object() takes no parameters')
>
>
> Except in C, of course.
>
> This is probably a left-over from the days when object() took and
> ignored any parameters. If my guess is close, then maybe we can do this:
>
>         if args:
>              raise TypeError('%s() takes no parameters' % cls.__name__)
>
>
> or equivalent.
>
> --
> Steve
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
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/9f809a91/attachment-0001.html>


More information about the Python-ideas mailing list