[Python-ideas] Is this PEP-able? for X in ListY while conditionZ:

Anders Hovmöller boxed at killingar.net
Tue Jun 25 20:15:29 CEST 2013


So is your suggestion, but it has a different name. If your teacher is this
easily fooled, get a new teacher.


On Tue, Jun 25, 2013 at 8:03 PM, <jimjhb at aol.com> wrote:

> That's a break....
>
>
>
> -----Original Message-----
> From: Shane Green <shane at umbrellacode.com>
> To: Ned Batchelder <ned at nedbatchelder.com>
> Cc: python-ideas <python-ideas at python.org>
> Sent: Tue, Jun 25, 2013 1:13 pm
> Subject: Re: [Python-ideas] Is this PEP-able? for X in ListY while
> conditionZ:
>
>  [x for x in l if x < 10 else break]?
>
>
>
>
>  On Jun 25, 2013, at 10:08 AM, Ned Batchelder <ned at nedbatchelder.com>
> wrote:
>
> You don't have to: use the break statement, that's what it's for.   About
> people teaching students not to use it: the existence of bad teachers
> teaching silly ideas is not a reason to add syntax to Python.
>
> --Ned.
>
> On 6/25/2013 10:46 AM, jimjhb at aol.com wrote:
>
>
>  You shouldn't have to invoke takewhile and a lambda just to break out of
> for loop.
>
> >http://docs.python.org/2/library/itertools.html#itertools.takewhile
> >
> >for item in takewhile(lambda x: x < 5, range(10)):
> >    pass
> >>
> >> [People who avoid the 'break' by functionalizing an inner portion of the
> >> loop are just kidding themselves and making their own code worse, IMO.
> >> Takewhile from itertools also works, but that's clumsy and wordy as well.]
> >>
>
>
>
>
> _______________________________________________
> Python-ideas mailing listPython-ideas at python.orghttp://mail.python.org/mailman/listinfo/python-ideas
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>
>   _______________________________________________
> Python-ideas mailing listPython-ideas at python.orghttp://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/20130625/2599c9f0/attachment.html>


More information about the Python-ideas mailing list