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

Guido van Rossum guido at python.org
Wed Sep 6 12:43:53 EDT 2017


I'm actually not in favor of this. It's another way to do the same thing.
Sorry to rain on your dream!

On Wed, Sep 6, 2017 at 9:34 AM, R. David Murray <rdmurray at bitdance.com>
wrote:

> On Wed, 06 Sep 2017 15:05:51 +1000, Chris Angelico <rosuav at gmail.com>
> wrote:
> > 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)
>
> Yes.
>
> > Or this, which uses the condition purely as a descriptor:
> >
> > while "moar socket data":
> >     data = sock.read()
> >     break if not data
> >     process(data)
>
> Yes.
>
> > Also - shouldn't this be being discussed first on python-ideas?
>
> Yep, you are absolutely right.  Someone has told me I also missed
> a related discussion on python-ideas in my searching for prior
> discussions.  (I haven't looked for it yet...)
>
> I'll blame jet lag :)
>
> --David
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170906/516617bd/attachment.html>


More information about the Python-Dev mailing list