try..except with empty exceptions

Ian Kelly ian.g.kelly at gmail.com
Sat Apr 11 14:49:08 EDT 2015


On Apr 11, 2015 5:06 AM, "Steven D'Aprano" <
steve+comp.lang.python at pearwood.info> wrote:
>
> Yes, I agree that Python's behaviour here is better than the alternative.
> Having "except ()" catch nothing is consistent with the behaviour with
> other tuples, so I'm okay with that. But it still surprised me :-)

There's another alternative that I haven't seen suggested yet. An empty
tuple could be considered an indication of a programming error and raise a
chained ValueError.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150411/ca54db3c/attachment.html>


More information about the Python-list mailing list