On Mar 19, 10:52 pm, Márcio Faustino <m.faust...@gmail.com> wrote: > Hi, > > Executing the example below doesn't produce the expected behavior, but > using the commented code does. Is this normal, or is it a problem with > Python?
It is a common gotcha. Notice that it has nothing to do with lambda functions, you would get the same issue with regular functions. This post http://www.artima.com/forums/flat.jsp?forum=106&thread=251156 and especially the comments below should share some light on why it is the way it is (short answer: for loops are implemented by mutating the loop variable at each iteration). -- http://mail.python.org/mailman/listinfo/python-list