__getattribute__'s error is not available in __getattr__

Ethan Furman ethan at stoneleaf.us
Wed May 3 01:05:30 EDT 2017


On 05/02/2017 09:57 PM, Chris Angelico wrote:
> 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...

Indeed?  I heard about them!  Seems they're going to drive cod pieces out of style.  ;)

--
~Ethan~




More information about the Python-list mailing list