
On Sat, Dec 28, 2013 at 12:05 PM, Andrew Barnert <abarnert@yahoo.com> wrote:
Would there be a use for a sequence like this without except on the end (so if they all fail, it just raises)?
I think what you're talking about is just leaving the try off the last clause (as in the example below).
Can you put an exception type or tuple between the "except try"? What about an as clause (so the block could use it)?
I started writing a mail with exactly this subject line and discarded it because of the latter two issues. In code I've recently written I have a chain of three and while the indentation is ugly, it's not so ugly that it cries out as a must fix language feature. And the problem is that I really want to limit to specific exceptions. In one case I have something like this: try: .... except KeyError: try: .... except AttributeError: try: .... except IndexError: .... and if I can't specify the specific exception, this is not helpful. On the other hand try: .... except KeyError try: .... except AttributeError try: .... except IndexError: .... only really saves me two colons and some whitespace. If the language had this feature, I'd use it, but that doesn't make it worth adding. --- Bruce