title: Does an equivalent of override exist for nested functions?
body: <p>If I have this function, what should I do to replace the inner function with my own custom version?</p>
  
  <pre><code>def foo():
      def bar():
          # I want to change this
          pass
  
      # here starts a long list of functions I want to keep unchanged
      def baz():
          pass
  </code></pre>
  
  <p>Using classes this would be easily done overriding the method. Though, I can't figure out how to do that with nested functions. Changing <code>foo</code> to be a class (or anything else) is not an option because it comes from a given imported module I can't modify.</p>