[EMAIL PROTECTED] wrote: > What I want is, the value of i should be bounded to the anonymous > function. And the output should like this: ... > How to achieve this?
This doesn't answer your question (others have), but another (perhaps clearer) way to do such things is something like class MyFunc(object): """A function object.""" def __init__(self, val): self.val = val def __call__(self): """Return value squared""" return self.val**2 a = [] for i in range(4): a.append(MyFunc(i)) for f in a: f() Jeremy -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list