generator expression works in shell, NameError in script

greg greg at cosc.canterbury.ac.nz
Sat Jun 20 05:58:56 CEST 2009


ryles wrote:
> However, in 3.0 list
> comprehensions are actually treated as list(<generator>).

That's not quite true -- it would be rather inefficient
if it was. The code generated for the LC is much the same
as it was in 2.x. But the whole LC is put into a nested
function so that the loop variables are local to it.

-- 
Greg



More information about the Python-list mailing list