__getattribute__'s error is not available in __getattr__

Chris Angelico rosuav at gmail.com
Wed May 3 00:57:14 EDT 2017


On Wed, May 3, 2017 at 2:39 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 05/02/2017 07:47 PM, Chris Angelico wrote:
>>
>> On Wed, May 3, 2017 at 12:37 PM, Ethan Furman wrote:
>
>
>>> Until then Chris' decorator is probably the easiest work around -- but
>>> you
>>> should only catch AttributeError, not everything.
>>
>>
>> It does. (Or rather, it catches only those exception(s) listed as
>> parameters.) Any other exceptions pass through unchanged.
>
>
> Ah, that's what I get for skimming!

I was going to hardcode AttributeError, which would have made it more
obvious and simpler, but then a single-purpose decorator (and if you
do that, why not just wrap your code in try/except manually?).
Obviously for production it needs a codstring...

ChrisA



More information about the Python-list mailing list