If I have this function, what should I do to replace the inner function with my own custom version?
def foo(): def bar(): # I want to change this
You can pass it in as an optional parameter
def foo(bar=None): def _bar(): # I want to change this pass if bar is None: bar = _bar