list comprehension question

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Wed May 6 05:26:25 EDT 2009


John Yeung schreef:
> Essentially, if you see [B A] over and over and over again, when
> finally confronted with LCs of more "elements", it's not immediately
> clear that the pattern of increasing nestedness is
> 
>   [B A] => [C A B] => [D A B C] => etc.
> 
> rather than
> 
>   [B A] => [C B A] => [D C B A] => etc.
> 
> Maybe we're wired wrong, but there are many of us who find the second
> pattern more logical, which is why it is so easy for us to mess up the
> order of the nesting in a more complex LC.

Indeed, that is exactly the reason why I find it difficult to read
nested loop comprehensions, and why I almost never use them.

-- 
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven



More information about the Python-list mailing list