[Python-ideas] syntax to continue into the next subsequent except block
Paul Wiseman
poalman at gmail.com
Sat Sep 15 10:21:40 CEST 2012
On 14 September 2012 02:52, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> Terry Reedy writes:
>
> > try:
> > try:
>
> Ugh-ugh.<0.5 wink>
>
> > try:
> > operation()
> > except Exception as err:
> > if isinstance(err, IOError) and err.errno == 2:
>
> Ugh.<0.5 wink>
>
> Not your fault, but these constructions are pretty ugly IMO, I have to
> go with the OP on that.
>
> ISTR there were discussions of "qualified except" clauses here maybe
> 6mo to 1yr ago? That is, they'd look something like
>
> try:
> operation()
> except IOError as err if err.errno == 2:
> do_something()
> except Exception:
> logger.error("Error performing operation: {}".format(err.message)")
> some_clean_up()
> raise
>
> Again ISTR that this got spiked for some reason, but maybe it will be
> of use to the OP in formulating his next idea. Sorry for the lack of
> precise reference.
>
I like that "qualified except". Almost goes without saying it's a much
better idea/solution that my idea of a continue (which has already pointed
out to be flawed- I'm not sure why now I thought it was always a syntax
error)
> _______________________________________________
> 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/20120915/8e834961/attachment.html>
More information about the Python-ideas
mailing list