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/2017-September/149191.html below:

[Python-Dev] PEP 548: More Flexible Loop Control

[Python-Dev] PEP 548: More Flexible Loop Control [Python-Dev] PEP 548: More Flexible Loop ControlChris Angelico rosuav at gmail.com
Wed Sep 6 01:05:51 EDT 2017
On Wed, Sep 6, 2017 at 10:11 AM, R. David Murray <rdmurray at bitdance.com> wrote:
> I've written a PEP proposing a small enhancement to the Python loop
> control statements.  Short version: here's what feels to me like a
> Pythonic way to spell "repeat until":
>
>     while:
>         <do stuff>
>         break if <done condition>
>
> The PEP goes into some detail on why this feels like a readability
> improvement in the more general case, with examples taken from
> the standard library:
>
>      https://www.python.org/dev/peps/pep-0548/

Is "break if" legal in loops that have their own conditions as well,
or only in a bare "while:" loop? For instance, is this valid?

while not found_the_thing_we_want:
    data = sock.read()
    break if not data
    process(data)

Or this, which uses the condition purely as a descriptor:

while "moar socket data":
    data = sock.read()
    break if not data
    process(data)

Also - shouldn't this be being discussed first on python-ideas?

ChrisA
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