On Oct 15, 1:01 pm, looping <[EMAIL PROTECTED]> wrote: > So if I understand what Michele wrote (thanks too), when a function is > defined (with def), no scope is saved and every variable value not > passed in parameter is lost ? It means that variable value come from > the outer scope when the function is called ?
Yes, in my example you get the value of "i" at the function *calling* time, not at the function definition time. If you want to store the value at the definition time, you must use the default argument trick: funclist = [] for i in 1,2,3: def f(i=i): print i funclist.append(f) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list