Counting nested loop iterations

Duncan Booth duncan.booth at invalid.invalid
Fri Mar 17 16:53:18 CET 2006

Diez B. Roggisch wrote:

>> Which is utterly counter-intuitive, the opposite of Perl, and remains
>> one of the most confusing and surprising things I have encountered in
>> Python so far.
> AFAIK stems from mathematics where you write things like
> {y | \forall x \in X : \forall y \in x }
> And so many people consider it pretty natural/intuitive. After all, we
> read from left to right, and making something depend from something
> yet to be introduced is counter-intuitive in my book. YMMV though.
I think the problem is that y is used before the loop which creates it, but 
x is used after the loop which creates it.

People can cope with the expanded loop form where everything it is used 
after it is introduced, and it would appear that they also cope well with 
the perl way of doing everything backwards, but moving the last element to 
the front while keeping everything else in the 'correct' order seems to 
confuse a lot of people.

Oh well, just wait until Python 2.5 comes out and we get people complaining 
about the order of the new if statement.

More information about the Python-list mailing list