[Tutor] implied tuple in a list comprehension
Jim Mooney
cybervigilante at gmail.com
Fri Aug 2 10:02:01 CEST 2013
On 2 August 2013 00:46, Alan Gauld <alan.gauld at btinternet.com> wrote:
> On 02/08/13 08:32, Jim Mooney wrote:
> How should Python interpret this?
>
> As
>
> x = [idx, (word for idx, word in S)]
>
> Or
>
>
> x = [(idx, word) for idx, word in S]
>
> It's ambiguous.
>
I see what you mean, but I figured it can't be ambiguous if one
interpretation makes no sense, and I can't see what x = [idx, (word
for idx, word in S)] could possibly mean. Am I assuming too much
foresight on the part of the parser or does that actually mean
something?
--
Jim
Just remember, food faddists, the first three letters of Diet are DIE!
More information about the Tutor
mailing list