[Python-Dev] PEP 3142: Add a "while" clause to generator expressions
Ludvig Ericson
ludvig at lericson.se
Wed Jan 21 18:32:37 CET 2009
The following was supposed to go to the list:
18:29 Gerald Britton:
> Yes you could have long lines, but you wouldn't have to use it. You
> could still code it up as you would today. It might be convenient for
> shorter expressions though.
>
> 12:12 PM Ludvig Ericson:
>> On Jan 21, 2009, at 16:51, Gerald Britton wrote:
>>
>>> for <item> in <iterable> [while [<predicate> | not <predicate>]:
>>> <suite>
>>
>> (Sorry for just sort of popping in to the list.)
>>
>> That would make for some very, very long lines. I for one wouldn't
>> like
>> seeing:
>>
>>>>> for cart_item in current_user.cart.new_items \
>> ... while cart_item.cant_imagine_more:
>> ... <body>
>>
>> I realize that the other approach--an immediate if-break--wouldn't
>> look
>> great either, but it wouldn't be cramming that much stuff into one
>> line.
More information about the Python-Dev
mailing list