[Python-ideas] Fwd: Null coalescing operator

Guido van Rossum guido at python.org
Mon Sep 12 11:37:11 EDT 2016


For the record, I still really don't like PEP 463. We should strive to
catch fewer exceptions, not make it easier to catch them.

On Mon, Sep 12, 2016 at 7:09 AM, Chris Angelico <rosuav at gmail.com> wrote:
> On Tue, Sep 13, 2016 at 12:03 AM, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
>> Assuming you can't break existing code that already traps TypeError,
>> AttributeError, etc., I don't see how you can do this without
>> having separated kinds of NoneError which were subclasses of TypeError,
>> AttributeError, etc.
>
> class NoneError(Exception): pass
> class TypeNoneError(TypeError, NoneError): pass
> class AttributeNoneError(AttributeError, NoneError): pass
>
> Now you can catch NoneError to catch None.xyz, or AttributeError to
> catch foo.xyz for any foo.
>
> I don't think it's good, but it's possible.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list