adding new functionality to a function non-intrusively!
mjs7231
mjs7231 at gmail.com
Wed Feb 16 09:55:30 EST 2005
Whenever I want to add functionality to a function while still allowing
it to word as it was before my edit would be to include a few optional
variables passed to the string. something to this effect would look
like:
------------------------------------------
BEFORE:
------------------------------------------
def myfunction(a, b):
return (a + b)
------------------------------------------
AFTER:
------------------------------------------
def myfunction(a, b, op="add"):
if (op == "add"):
return (a + b)
else:
return (a - b)
------------------------------------------
More information about the Python-list
mailing list