Re: Is the behavior expected?

2008-11-26 Thread Alphones
all the discussions are very helpful to me. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is the behavior expected?

2008-11-26 Thread Alphones
On 11月27日, 上午12时07分, Peter Otten <[EMAIL PROTECTED]> wrote: > Alphones wrote: > > On 11月26日, 下午9时28分, [EMAIL PROTECTED] wrote: > >> Alphones: > > >> > it is a little deferent from other script language. > > >> See also here:http://en.wikipedia.o

Re: Is the behavior expected?

2008-11-26 Thread Alphones
On 11月26日, 下午9时28分, [EMAIL PROTECTED] wrote: > Alphones: > > > it is a little deferent from other script language. > > See also here:http://en.wikipedia.org/wiki/Dynamic_scope#Dynamic_scoping > > Python doesn't have such automatic closures, probably for performance &

Re: Is the behavior expected?

2008-11-26 Thread Alphones
On 11月26日, 下午8时48分, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Alphones wrote: > > Hi all, > > > def getFunc(x): > > return lambda y : x + y > > > if __name__ == '__main__': > > todo = [] > > proc = g

[lambda]Is the behavior expected?

2008-11-26 Thread Alphones
Hi all, def getFunc(x): return lambda y : x + y if __name__ == '__main__': todo = [] proc = getFunc(1) todo.append(lambda: proc(1)) proc = getFunc(2) todo.append(lambda: proc(1)) proc = getFunc(3) todo.append(lambda: proc(1)) todo.append(lambda: getFunc(1)(1)