a break for comprehensions

Alex Martelli aleaxit at yahoo.com
Thu Aug 2 07:42:57 EDT 2001


"Paul Svensson" <paul at svensson.org> wrote in message
news:9k44u5$fua$1 at newsy.ifm.liu.se...
    ...
> never see list comprehensions a procedural description for how
> to generate the list, but rather a symbolic description of
> the list content.  With that view it shouldn't matter which
> for-clause gets evaluated innermost, and so the only unambigous

Sorry, but it still does: [x-y for x in range(4) for y in range(4)]
is [0, -1, -2, -3, 1, 0, -1, -2, 2, 1, 0, -1, 3, 2, 1, 0], while
[x-y for y in range(4) for x in range(4)] is the different list
[0, 1, 2, 3, -1, 0, 1, 2, -2, -1, 0, 1, -3, -2, -1, 0].  They
might be the same if seen as sets, but, as lists, they aren't.


Alex






More information about the Python-list mailing list