"Tim Golden" <[EMAIL PROTECTED]> wrote
In fact I guess you could say that the new definition of a list
comprehension is
[ generator expression]
Well, not if sure if you meant that literally
No I meant in syntactic terms.
We usually define an LC as
[ expr for vars in sequence if expr ]
or somesuch imprecise gobbledy gook ;-).
Now we can define the generator expr (syntax) as
expr for vars in sequence if expr
and the LC as
[ gen expr ]
<code>
squares = (x * x for x in range (10))
l = [squares]
But doesn't that generate a tuple (because of the parens)?
And if you remove the parens you cant assign to the
variable so you have to [put it in the list literally which becomes
l = [x * x for x in range (10)]
Which is an LC...
Alan G.
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor