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

Tim Golden mail at timgolden.me.uk
Mon Mar 7 11:38:09 EST 2016


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



More information about the Python-list mailing list