On Mon, Sep 12, 2016, at 06:01, Ivan Levkivskyi wrote: > I like this idea, I would propose a (maybe crazy) addition to it. What > about a special exception NoneError, that will catch TypeError, > AttributeError etc. but only when it was caused by None(), > None.attr, None[1], etc. With this one can write: > > x = a.b()[0] except NoneError: 'default' > > without a risk of catching other (unrelated) exceptions.
Unless there's another None somewhere inside b or b().__getitem__. _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/