Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: How to get which attribute causes the AttributeError except inspecting strings? Date: Mon, 7 Mar 2016 17:26:11 +0000 Lines: 31 Message-ID: References: <7915b82e-12f4-4652-999e-a1cfaca717b6@googlegroups.com> <56DDAE71.1030100@timgolden.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de gcYHKOXZb74O4YRdqUWNgwons0gkQC7MyWC1yJrCDrRw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'seemed': 0.07; 'subject:How': 0.09; 'chime': 0.09; 'issue:': 0.09; 'raised,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:which': 0.09; 'exception': 0.13; 'subject: \n ': 0.15; "can't.": 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'tjg': 0.16; 'wrote:': 0.16; 'string': 0.17; 'attribute': 0.18; 'language': 0.19; 'lawrence': 0.22; 'seems': 0.23; 'thanks,': 0.24; 'tim': 0.24; 'header:In-Reply- To:1': 0.24; 'discussion': 0.24; 'url:bugs': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'inspect': 0.29; 'language.': 0.32; 'url:python': 0.33; 'raised': 0.33; 'involving': 0.35; 'saved': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'possible': 0.36; '(and': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:org': 0.37; 'things': 0.38; 'hi,': 0.38; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'some': 0.40; 'hope': 0.61; 'caused': 0.61; 'bring': 0.62; 'back': 0.62; 'charset:windows-1252': 0.62; 'subject:skip:A 10': 0.63; 'more': 0.63; 'interest': 0.64; 'our': 0.64; 'forward': 0.66; 'life': 0.67; 'directly.': 0.76; 'interest.': 0.79; 'introduce': 0.79; 'subject:get': 0.81; 'movement.': 0.84; 'pythonistas,': 0.84; 'revive': 0.84; 'zhang': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 80.234.129.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <56DDAE71.1030100@timgolden.me.uk> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104232 On 07/03/2016 16:38, 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, you saved me searching for the link that I knew existed :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence