On Sep 28, 6:43 am, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > Hello all, > > To me, this is a somewhat unintuitive behavior. I want to discuss the > parts of it I don't understand. > > >>> f= [ None ]* 10 > >>> for n in range( 10 ): > > ... f[ n ]= lambda: n > ...>>> f[0]() > 9 > >>> f[1]() > > 9 >
You may want to read this old thread that goes in detail explaining scoping issues with closures in for loops: http://groups.google.com/group/comp.lang.python/browse_frm/thread/d691240a5cfebcdf/93503c5b9c66226e?hl=en&lnk=gst&q=simionato+jacek#93503c5b9c66226e -- http://mail.python.org/mailman/listinfo/python-list