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) fA = newFA gives an infinite recursive loop? kind regards Peter Antoon Pardon wrote: > Op 2005-02-16, peter schreef <[EMAIL PROTECTED]>: > > Hello all, > > > > Recently I've started to refactor my code ...(I'm using python 2.3.4) > > I tried to add extra functionality to old functions non-intrusively. > > When I used a construct, which involves renaming functions etc... I > > came across some recursive problems. (a basic construct can be found > > under the section BASIC CODE) > > > > These problems do not occur when renaming objects. (see section EXTRA > > CODE) > > My question now is: > > I do not know the underlying idea of functions. Is this the way they > > should behave? Or should they work the same way as objects do? > > (My preferences goes to this last option) > > > > BASIC CODE: > > --------------------------------------------------------------------------- > > def fA(input): # starting point: function named fA > > return input > > > > def newFA(input): # new function with added functionality > > #does something extra with a! > > return fA(input) > > fA = newFA > > # this should allow to add functionality without > > # breaking older code which uses the name fA! > > fA() # execute fA() > > Try this: > > def fA(input): > return input > > > def newFA(input, f= fA): > return f(input) > > fA = newFA > > -- > Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list