[Python-ideas] Order of loops in list comprehension

Sven R. Kunze srkunze at mail.de
Sat Oct 22 12:01:11 EDT 2016


On 22.10.2016 09:50, Alexander Heger wrote:
> Well, an argument that was often brought up on this forum is that 
> Python should do things consistently, and not in one way in one place 
> and in another way in another place, for the same thing.

Like * in list displays? ;-)

> Here it is about the order of loop execution.  The current behaviour 
> in comprehension is that is ts being done the same way as in nested 
> for loops.

It still would. Just read it from right to left. The order stays the same.

> Which is easy enough to remember.  Same way, everywhere.

I am sorry but many disagree with you on this thread.

I still don't understand why the order needs to be one-way anyway. 
Comprehensions are a declarative construct, so it should be possible to 
mix those "for .. in .."s up in an arbitrary order.

Cheers,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161022/51ea399a/attachment.html>


More information about the Python-ideas mailing list