title: How can I make a deepcopy of a function in Python?
body: <p>I would like to make a deepcopy of a function in Python.  The <em>copy</em> module is not helpful, according to the <a href="http://docs.python.org/library/copy.html" rel="noreferrer">documentation</a>, which says:</p>
  
  <blockquote>
    <p>This module does not copy types like module, method, stack trace, stack frame, file, 
    socket, window, array, or any similar types. It does “copy” functions and classes (shallow 
    and deeply), by returning the original object unchanged; this is compatible with the way
    these are treated by the pickle module.</p>
  </blockquote>
  
  <p>My goal is to have two functions with the same implementation but with different docstrings.  </p>
  
  <pre><code>def A():
      """A"""
      pass
  
  B = make_a_deepcopy_of(A)
  B.__doc__ = """B"""
  </code></pre>
  
  <p>So how can this be done?</p>