[Python-ideas] syntax to continue into the next subsequent except block

Paul Wiseman poalman at gmail.com
Mon Sep 17 12:51:30 CEST 2012


On 17 September 2012 05:20, Guido van Rossum <guido at python.org> wrote:

> On Sun, Sep 16, 2012 at 5:11 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
> wrote:
> > Guido van Rossum wrote:
> >>
> >> The suggestion to add ad-hoc "if <condition>" clauses to random parts
> >> of the syntax doesn't appeal to me at all.
> >
> >
> > I wouldn't call it a random part of the syntax. This is
> > not like the proposals to add if-clauses to while loops,
> > for loops, etc -- they would just be minor syntactic sugar.
> > This proposal addresses something that is quite awkward to
> > express using existing constructs.
>
> It can address an important use case and still be a random syntax
> change. I'm sure there are possible refactorings of the error handling
> from the examples that make it a lot less awkward. I don't think I've
> ever had a use case in my own code where I found it particularly
> awkward that I couldn't jump from one except clause to the next; I do
> remember some cases where I could simply write
>
>
I conceded that my idea of jumping from one except clause to the next was a
bad one, but with the except..if idea there would be no jumping; it would
work the same as it currently does where an exception can only enter at
most one except block in the same level of try..excepts.


>   try:
>     <code that may fail>
>   except <some exception>, err:
>     if <on further inspection we don't want to handle it>:
>       raise    # re-raise err
>     <special handling for some variant of the exception>
>
> This would possibly be combined with other except clauses but the
> would be no need for the 'raise' to transfer to one of these.
>
> --
> --Guido van Rossum (python.org/~guido)
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120917/254bf4ed/attachment.html>


More information about the Python-ideas mailing list