Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread Michael Spencer
peter wrote: brain reset and understood thx a lot for all your answers Peter Now that you've got reset, you might want to consider an alternative solution: def fA(input): return input oldfA = fA # Hold a reference to the the old function def newFA(input): "Do something new" return oldfA

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread Jeff Shannon
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.

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread peter
brain reset and understood thx a lot for all your answers Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread Fredrik Lundh
"peter" <[EMAIL PROTECTED]> wrote > > PYTHON-CODE # REMARKS > referenceA = SomeObject() # referenceA -> SomeObject() > # references to the memory space of >

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread Michael Spencer
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 d

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread Satchidanand Haridas
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: >>> def fA(input): ... print "inside fA" ... return input ... >>>

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread peter
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 newF

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread Antoon Pardon
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 re

Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread peter
see the topic: adding new functionality to a function non-intrusively! and decorators if you want to add functionality to a function! -- http://mail.python.org/mailman/listinfo/python-list