Re: [Python-ideas] Order of loops in list comprehension

2016-10-22 Thread Greg Ewing
C Anthony Risinger wrote: Erlang/Elixir (sorry after 6 years python this is what I do now!) does it the same way as python: >>> [{X, Y} || X <- [1,2,3], Y <- [a,b]]. [{1,a},{1,b},{2,a},{2,b},{3,a},{3,b}] Here X is the outer loop. I think the confusion stems from doing it both ways at the

Re: [Python-ideas] Order of loops in list comprehension

2016-10-22 Thread C Anthony Risinger
On Oct 22, 2016 2:51 AM, "Alexander Heger" wrote: >>> >>> For me the current behaviour does not seem unreasonable as it resembles the order in which you write out loops outside a comprehension >>> >>> >>> That's true, but the main reason for having comprehensions >>> syntax

Re: [Python-ideas] Order of loops in list comprehension

2016-10-22 Thread Sven R. Kunze
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

Re: [Python-ideas] Order of loops in list comprehension

2016-10-21 Thread Sven R. Kunze
On 21.10.2016 01:43, Greg Ewing wrote: Alexander Heger wrote: For me the current behaviour does not seem unreasonable as it resembles the order in which you write out loops outside a comprehension That's true, but the main reason for having comprehensions syntax in the first place is so that

Re: [Python-ideas] Order of loops in list comprehension

2016-10-20 Thread Greg Ewing
Alexander Heger wrote: For me the current behaviour does not seem unreasonable as it resembles the order in which you write out loops outside a comprehension That's true, but the main reason for having comprehensions syntax in the first place is so that it can be read declaratively -- as a

Re: [Python-ideas] Order of loops in list comprehension

2016-10-20 Thread Alexander Heger
For me the current behaviour does not seem unreasonable as it resembles the order in which you write out loops outside a comprehension except that the expression for generated values is provided first. On 21 October 2016 at 05:03, Sven R. Kunze wrote: > On 19.10.2016 00:08, Rob

Re: [Python-ideas] Order of loops in list comprehension

2016-10-20 Thread Sven R. Kunze
On 19.10.2016 00:08, Rob Cliffe wrote: But it's far too late to change it now, sadly. Indeed. :-( But if I were ruler of the world and could have my own wish-list for Python 4, this (as per the first example) would be on it. I don't see no reason why we can't make it. Personally, I also

Re: [Python-ideas] Order of loops in list comprehension

2016-10-18 Thread Rob Cliffe
On 18/10/2016 07:40, Greg Ewing wrote: Random832 wrote: For me, it's the fact that: [[a for a in b] for b in ['uvw', 'xyz']] == [['u', 'v', 'w'], ['x', 'y', 'z']] which makes me want to write: [a for a in b for b in ['uvw', 'xyz']] You're not alone! Lately I've been becoming convinced that