R. David Murray added the comment: I hear what you are saying, but the "generalization" does not mean that they work exactly the same way. The whole point of generators is that execution is lazy, which is what leads to the difference in behavior.
The generator function *is* closed over the free variables. That's what leads to the difference in behavior: the generator uses the value the free variable has when the generator executes. I don't believe there is any practical way to implement what you are suggesting, even if we wanted to...which we would not be, since it would constitute a backward incompatible change in behavior. Note also that this behavior of closures is not unique to Python. See for example http://www.javascriptkit.com/javatutors/closures2.shtml. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7423> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com