>>>>> data = ( >> ... (1,2), >> ... (3,4), >> ... ) >> >>>>> [x,y for a in data] >> File "<stdin>", line 1 >> [x,y for a in data] >> ^ >> SyntaxError: invalid syntax >> >> I expected: >> [(1, 2), (3, 4)] > > > Why would you expect that? I would expect the global variables x and y, or > if they don't exist, a NameError:
Thank you Steve (and everyone) for your answers. In answer to Steve's question above, it's because I can do this: >>> for x,y in data: ... pass ... >>> But, anyway, I see my error now, and I'm good to go. -- https://mail.python.org/mailman/listinfo/python-list