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-May/053342.html below:

[Python-Dev] PEP 340: Breaking out.

[Python-Dev] PEP 340: Breaking out.Ka-Ping Yee python-dev at zesty.ca
Wed May 4 21:20:09 CEST 2005
On Wed, 4 May 2005, Shane Hathaway wrote:
> I'd like to suggest a small language enhancement that would fix this
> example.  Allow the break and continue statements to use a keyword,
> either "for" or "while", to state that the code should break out of both
> the block statement and the innermost "for" or "while" statement.  The
> example above would change to:
>
>     for name in filenames:
>         opening(name) as f:
>             if f.read(2) == 0xFEB0:
>                 break for

This is very elegant.  It works beautifully with "break", though at
first that natural analogs "continue for", "continue while" appear to
conflict with Guido's proposed extension to "continue".

But if we choose the keyword "with" to introduce an anonymous block,
it comes out rather nicely:

    continue with 2

That's easier to read than "continue 2", in my opinion.  (If it's not
too cute for you.)

Anyway, i like the general idea of letting the programmer specify
exactly which block to break/continue, instead of leaving it looking
ambiguous.  Explicit is better than implicit, right?


-- ?!ng
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