ugliness :) so this is why [lambda: i for i in range(10)] will always return 9. imho that's a bug, not a feature.
thanks. -tomer Duncan Booth wrote: > "gangesmaster" <[EMAIL PROTECTED]> wrote: > > > what problem does the cell object solve? > > The closure represents the variable, not the object. So if x is rebound to > a different object your inner function g() will now access the new object. > If the object itself was passed to MAKE_CLOSURE then g would only ever see > the value of x from the instant when g was defined. > > >>> def f(x): > def g(): > print "x is", x > g() > x += 1 > g() > > > >>> f(1) > x is 1 > x is 2 -- http://mail.python.org/mailman/listinfo/python-list