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

Shane Green shane at umbrellacode.com
Sat Jun 29 18:33:00 CEST 2013


I see your point.  I’m wondering if there’s a formatting convention or something that might suffice.  Tried a couple but have’t come up with anything neat.  

>> data = [x for x in iterable

>>             break if x is None]

>> data = [x for x in utterable 	break if x is None]


I don’t necessarily think this makes the options any more difficult to parse than they were previously; advanced comprehensions can get a bit unwieldy already.  With syntax highlighting a color coded “break” keyword separates the generation from the termination.  



On Jun 29, 2013, at 8:46 AM, Joshua Landau <joshua.landau.ws at gmail.com> wrote:

> On 29 June 2013 11:09, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> Rather than adding a new keyword, we could simply expand the syntax
>> for the existing break statement to be this:
>> 
>>    break [if <EXPR>]
> ...
>> Once the break statement has been redefined this way, it *then*
>> becomes reasonable to allow the following in comprehensions:
>> 
>>    data = [x for x in iterable break if x is None]
> 
> Almost all of your proposal looks reasonable, but I personally find
> this quite hard to read; it should be written along the lines of (I'm
> not proposing this):
> 
>    x for x in iterable; break if x is None
> 
> if one is to continue having syntax that is pseudo-correct English - a
> trait I am eager to to keep.
> 
> In summary, this is hard for me to read because there is no separation
> of the statements.
> 
> 
> Because I have not other substantial objections, I'm -0 on this. If
> you can find a way to "fix" that, I'll be, for all intents and
> purposes, neutral.
> _______________________________________________
> 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/20130629/68968c3e/attachment-0001.html>


More information about the Python-ideas mailing list