On 13 Dec 1999 01:39:12 +0100, Magnus L. Hetland wrote:
Is list comprehension on its way into the language? Or is that just a
rumour, based on Greg's patch?
I hope it's going it.
And - as allways, I can't leave the syntax alone without a suggestion
of my own... Greg's patch works like this (among other things):
The amusing thing is that I tried to do the exact same thing as you're
about to try.
[(i, s) for i in nums for s in strs]
To me, this sounds a bit like
[(i, s) for i in [nums for s in strs]]
which I guess doesn't give much meaning. I think the syntax would be
clearer (and more natural language-like) with an "and" instead of the
"for"s, after the first one. The first ones marks that this is the
list of (i, s) for all of the "i"s and all of the "s"s given. Thus:
[(i, s) for i in nums and s in strs]
First of all, notice that "nums and s" is a valid parse of the middle of
this string. Thus, it's ambiguous.

Second, even if it wasn't, you forgot that 'if' is a valid keyword in such
a comprehension.
-William "Billy" Tanksley, in hoc signo hack

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 4 | next ›
Discussion Overview
grouppython-list @
postedDec 13, '99 at 12:39a
activeDec 13, '99 at 10:29p



site design / logo © 2022 Grokbase