[Python-ideas] Break if *condition*

Darren McCleary darren.rmc at gmail.com
Tue May 20 06:27:38 CEST 2014


Hello,

This is my first python idea suggestion. I often find myself writing code
like:

for i in iterable:
    # do something
    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

It seems to me this would be logical and in the same vein of conditional
variable assignments ( i.e. x = 0 if y == True else 1 )

Thoughts?


Cheers,
Darren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140520/e485326f/attachment.html>


More information about the Python-ideas mailing list