[FP] Rewriting name bindings as expressions

Richard Davies richardd at pobox.com
Fri May 25 14:14:37 CEST 2001


> ans = [y+1 for x in range(10) for y in (x*x,)]

Yes, that's seriously good. Also has the great advantage
that you can do

ans = [z+1 for x in range(10) for y in (x*x,) for z in (2*y,)]

without extra complexity, whereas I can't use y in z without
another layer of lambdas.

Richard.



More information about the Python-list mailing list