[Python-ideas] Break if *condition*

Chris Angelico rosuav at gmail.com
Tue May 20 07:23:47 CEST 2014


On Tue, May 20, 2014 at 2:27 PM, Darren McCleary <darren.rmc at gmail.com> wrote:
>     if i == some_condition :
>         break
>
> I feel that condensing this down to one line would be a novel idea. That
> same 2 lines could be written as:
>
> for i in iterable:
>     # do something
>     break if i == some_condition

if i == some_condition: break

That's one line too, and works on existing Python interpreters :)

ChrisA


More information about the Python-ideas mailing list