adding new functionality to a function non-intrusively!

peter Peter.Vandersteegen at gmail.com
Wed Feb 16 10:05:48 EST 2005


Hello

I indeed also rely on your idea.
My problem however is: is has to be non-intrusively in both ways.

In your example, it would indeed not break the old code which relies on
myfunction
but my problems is: I also do not want to change the code of the
'before' myfunction.

so my problem in fact  is:
BEFORE:
def myfunction(a,b):
      return (a+b)
AFTER:
def myfunction(a,b, op="add"):
       if (op == "add"):
              # some function which calls the old code for myfunction

kind regards




More information about the Python-list mailing list