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 > reasons and/or maybe to keep its C implementation simpler (maybe other > people here can give you an explanation of this, I too am curious). > > Bye, > bearophile
i encountered this problem when i'm writing a program for packaging files. the program generates tasks according to description file. and tasks are deferent from each other, and should be excuted at the last of program. i have experience on Lua and have learned about scheme and haskell, so i wrote the wrong code in python. now my solution is, using class taskCreator to create tasks and put them into tasklist. class taskCreator: def __init__(self, proc, input, output): self.proc = proc self.input = input self.output = output def call(self): return self.proc.call(self.input, self.output) 'proc' is generated by procCreators, it's specified. it looks more complex than lambda one. is there any other simple way to implement it? and does the taskCreator mean 'create a new scope'? Suggestions will be appreciated. Thanks. PS: i'm a newbie in Python (started from today) -- http://mail.python.org/mailman/listinfo/python-list