[Python-ideas] while conditional in list comprehension ??

Nick Coghlan ncoghlan at gmail.com
Tue Jan 29 14:35:56 CET 2013


On Tue, Jan 29, 2013 at 11:08 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On 29/01/13 21:44, Nick Coghlan wrote:
>>
>> On Tue, Jan 29, 2013 at 11:30 AM, Steven D'Aprano<steve at pearwood.info>
>> wrote:
>>>
>>> Why would it translate that way? That would be a silly decision to make.
>>> Python can decide on the semantics of a while clause in a comprehension
>>> in
>>> whatever way makes the most sense, not necessarily according to some
>>> mechanical, nonsensical translation.
>>
>>
>> Terry is correct: comprehensions are deliberately designed to have the
>> exact same looping semantics as the equivalent statements flattened
>> out into a single line, with the innermost expression lifted out of
>> the loop body and placed in front.
>
>
>
> You have inadvertently supported the point I am trying to make: what is
> *deliberately designed* by people one way can be deliberately designed
> another way instead. List comps have the form, and limitations, they
> have because of people's decisions. People could decide differently.

"People" could. I'm telling you *we* (as in python-dev) won't.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list