In message <87k4oah1rp....@dpt-info.u-strasbg.fr>, Alain Ketterlin wrote:
> Lawrence D'Oliveiro <l...@geek-central.gen.new_zealand> writes: > >> No, I deliberately put it in that order to ensure that the value for l >> can only ever be evaulated once. > > Try this (essentially equivalent to your code): > > def f(): > print "hello" > return 1 > > V = tuple( 1 for x in [1,2,3] for l in (f(),) ) > > How many "hello"s do you see? > > Comprehension are not loops spelled backwards. The values in: > > whatever for i ... for j ... > > are the values produced by the equivalent code: > > for i ... > for j ... > whatever Damn. I thought that e for i ... for j ... was equivalent to (e for i ...) for j ... Looks like I was wrong. -- http://mail.python.org/mailman/listinfo/python-list