title: Hook python module function
body: <p>Basically I want to do something like this:
  <a href="https://stackoverflow.com/questions/22933287/how-can-i-hook-a-function-in-a-python-module">How can I hook a function in a python module?</a></p>
  
  <p>but I want to call the old function after my own code.</p>
  
  <p>like</p>
  
  <pre><code>import whatever
  
  oldfunc = whatever.this_is_a_function
  
  def this_is_a_function(parameter):
      #my own code here
      # and call original function back
      oldfunc(parameter)
  
  whatever.this_is_a_function = this_is_a_function
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>I tried <code>copy.copy</code>, <code>copy.deepcopy</code> original function but it didn't work.</p>