On Tue, Sep 13, 2016 at 12:03 AM, Rob Cliffe <rob.cli...@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@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to