[Python-ideas] except expression

Andrew Barnert abarnert at yahoo.com
Tue Feb 18 19:11:59 CET 2014


On Feb 18, 2014, at 9:51, Chris Angelico <rosuav at gmail.com> wrote:

> On Wed, Feb 19, 2014 at 4:45 AM, Andrew Barnert <abarnert at yahoo.com> wrote:
>> If people do want to follow this, one thing to consider: we don't have to
>> fiddle with the exception hierarchy; you can always override
>> issubclass/isinstance by either using an
>> ABC, or doing the same thing ABCMeta does. That would allow someone who
>> wanted to catch some type of error that isn't usually considered an
>> "expression error" but is commonly raised in expressions in their particular
>> project to add that error.
> 
> Actually, I'm not sure that you can. Give it a try! The only thing you
> can try to catch is a subclass of BaseException. But creating a tuple
> would work.

But if I define two new BaseException subclasses, and register one as a subclass of the other after the fact, I believe it works. (I can't test until I get in front of a computer with Python 3 on it.) That's what I was suggesting--being able to add thirdpartymodule.error to the expression errors, not being able to add, say, deque.


More information about the Python-ideas mailing list