| Store | Cart

[Tutor] List comprehensions

From: Blake Winton <bwin...@latte.ca>
Thu, 13 Jan 2005 15:03:16
Kent Johnson wrote:
>>> If you mean for j to be a list of foobar(item) then use>>> j=[foobar(item) for item in x]>>> The first part of the list comp can be any valid expression.>> Does that mean that there are invalid expressions? I'd enjoy seeing an >> example.> I suppose if it's an expression, it must be valid, eh? Otherwise it's > something else.

I don't think I entirely agree...  What about "x === item"  It's 
certainly not a statement, and I would wager that Python was in the 
middle of its expression parsing code when it threw the SyntaxError. 
(Or how about "x == item ="?)  Perhaps someone more in touch with the 
compiler internals will chip in here.

It is an interesting philosophical question, though.

Later,
Blake.

Recent Messages in this Thread
Liam Clarke Jan 13, 2005 12:37 am
jfo...@paradise.net.nz Jan 13, 2005 12:47 am
Kent Johnson Jan 13, 2005 12:48 am
Liam Clarke Jan 13, 2005 01:42 am
Bob Gailer Jan 13, 2005 02:08 am
Max Noel Jan 13, 2005 02:44 am
Bob Gailer Jan 13, 2005 05:08 am
Max Noel Jan 13, 2005 01:23 pm
Kent Johnson Jan 13, 2005 03:05 am
Blake Winton Jan 13, 2005 03:03 pm
Kent Johnson Jan 13, 2005 04:52 pm
Bob Gailer Jan 13, 2005 07:37 pm
Messages in this thread