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)

fA = newFA

is correct and:
-------------infinite loop-----------------

def fA(input):
  return input

def newFA(input):
   return fA(input)

In newFA, fA is not bound until you call newFA. By which time you've re-bound fA to newFA, causing the recursion. In the 'correct' solution above, f is bound to the original fA function at the time the def fA statement is executed, which is what you want.



fA = newFA

gives an infinite recursive loop?

kind regards

Peter

Regards Michael

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to