A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-June/054048.html below:

[Python-Dev] PEP 343 rewrite complete

[Python-Dev] PEP 343 rewrite completePhillip J. Eby pje at telecommunity.com
Wed Jun 1 22:26:44 CEST 2005
At 10:00 PM 6/1/2005 +0200, Eric Nieuwland wrote:
>Phillip J. Eby wrote:
> > At 08:46 PM 6/1/2005 +0200, Eric Nieuwland wrote:
> >> If I look at the translation it an augmented 'try'.
> >>         with EXPR as VAR:
> >>                 BLOCK1
> >>         except EXCEPTION:
> >>                 BLOCK2
> >> could then be translated to
> >
> > -1, too confusing.
>
>A matter of taste, I guess. IMHO 'with' secretly handling exceptions is
>confusing.

It doesn't secretly handle them; it simply gets access to them, which is an 
entirely different thing.

By confusing, I mean that it is not clear from your construct what 
exceptions are caught by the 'except' clause, due to its structural 
layout.  It's also not clear whether the __enter__/__exit__ of EXPR wrap 
BLOCK1 only, or both BLOCK1 and BLOCK2.  These aspects are "confusing" 
because whatever decision you make about the semantics, someone will have 
to *remember* them, as opposed to being unambiguously represented by the 
block structure.

By contrast, if you remove the except: clause from your construct, it is 
clear that BLOCK1 is what is wrapped, and there is no possible confusion 
about who sees what exceptions.  Exceptions inside the block are 
communicated to __exit__, exceptions outside (including those in the 'with' 
statement itself) are not.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4