peter wrote:
Hello, nice solution: but it puzzles me :)
can anyone tell me why -----------correct solution---------------- def fA(input): return input
def newFA(input, f= fA): return f(input)
This saves a reference to the original function in the new function's default argument.
-------------infinite loop-----------------
def fA(input): return input
def newFA(input): return fA(input)
This does not save any reference to the original function; it simply does a run-time lookup of the name, and uses whatever object is currently bound to that name. Since you later rebind the name to this new function, it's simply calling itself.
Jeff Shannon Technician/Programmer Credit International
-- http://mail.python.org/mailman/listinfo/python-list