[Python-ideas] syntax to continue into the next subsequent except block

Chris Rebert pyideas at rebertia.com
Sun Sep 16 23:32:12 CEST 2012


On Sun, Sep 16, 2012 at 1:51 PM, Joshua Landau
<joshua.landau.ws at gmail.com> wrote:
> Instead of adding syntax, we could make except use isinstance.
<snip>
> class SpecificOSErrorType(type):
> def __instancecheck__(cls, othercls):
> if isinstance(othercls, OSError):
<snip>
> class FileExistsOSError(OSError, metaclass=SpecificOSErrorType):
<snip>
> Disadvantages:
> - It doesn't work yet [*wink*]

There's actually an already-open bug regarding that:
"Catching virtual subclasses in except clauses"
http://bugs.python.org/issue12029

Cheers,
Chris



More information about the Python-ideas mailing list