"jfj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > def foo(x): > y= (i for i in x) > return y > > From the disassembly it seems that the generator is a code object
What is type(foo([1,2,3])) ? > but 'x' is not a cell variable. WTF? As I understand it, the object 'x' binds to is immediately used to create the generator object. The local name is just a dummy that is not part of the result. I believe that the above is equivalent to def foo(x): def _(z): for i in z: yield i return _(x) although I suspect that the implementation builds the generator more directly. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list