How to get which attribute causes the AttributeError except inspecting strings?

Xiang Zhang zhangyangyu0614 at gmail.com
Mon Mar 7 12:01:37 EST 2016


On Tuesday, March 8, 2016 at 12:38:31 AM UTC+8, Tim Golden wrote:
> On 07/03/2016 16:25, Xiang Zhang wrote:
> > Hi,
> > 
> > I know I can get the attribute name in some way, but since I just
> > want the attribute name when an AttributeError caused by it raised, I
> > really don't want to inspect the string or introduce one more layer
> > over getattr. I hope I can get the attribute which causes the
> > exception from the AttributeError raised directly. But it seems I
> > can't.
> > 
> 
> As things stand, you can't. But if you were to chime in on this issue:
> 
>   https://bugs.python.org/issue18156
> 
> then you might bring discussion there back to life again and see some
> forward movement. There seemed to be a consensus (and involving some
> active developers) so it's possible that new interest might revive interest.
> 
> TJG

Thanks for mentioning the issue. I'll ping it to see if there is still anyone interested in it.



More information about the Python-list mailing list