Martin v. Löwis wrote: > Ron_Adam wrote: > > > > No, I did not know that you could pass multiple sets of arguments to > > nested defined functions in that manner. > > Please read the statements carefully, and try to understand the mental > model behind them. He did not say that you can pass around multiple > sets of arguments. He said that functions (not function calls, but > the functions themselves) are objects just like numbers. There is > a way of "truly" understanding this notion, and I would encourage > you to try doing so.
I have the same feeling as Martin and Bengt. That is, Ron you are still not getting the correct picture. The fact that you have three-level nested definition of functions is almost incidental: that's not the important part (despite the nested scope variables.) The important part is that you have to understand functions are objects. Perhaps this will make you think a bit more: x=1 if x==1: def f(): return 'Hello' else: def f(): return 'Bye' for x in range(3): def f(x=x): return x Do you realize that I have introduced 5 function objects in the above code? Do you realize that function objects could be created *anywhere* you can write a Python statement? Whether it's inside another function, or inside a if...else... statement, or inside a loop, doesn't matter. Whereever you can write a Python statement, you can create a function there. I don't know what your previous programming language is, but you have to stop treating functions as "declarations". The "def" is an executable statement. Another example: def f(): return f g = f()()()()()()()()()()() is perfectly valid. -- http://mail.python.org/mailman/listinfo/python-list