[Python-ideas] syntax to continue into the next subsequent except block
Rob Cliffe
rob.cliffe at btinternet.com
Sat Sep 15 12:20:49 CEST 2012
On 15/09/2012 09:21, Paul Wiseman wrote:
> On 14 September 2012 02:52, Stephen J. Turnbull <stephen at xemacs.org
> <mailto: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)
I really like this qualified except! It's meaning is intuitively
obvious - AND it's useful.
Rob Cliffe
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org <mailto:Python-ideas at python.org>
> http://mail.python.org/mailman/listinfo/python-ideas
>
>
>
>
> _______________________________________________
> 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/6e8725b3/attachment.html>
More information about the Python-ideas
mailing list