title: Python introspection: access function name and docstring inside function definition
body: <p>Consider the following python code:</p>
  
  <pre><code>def function():
      "Docstring"
  
      name = ???
      doc = ???
  
      return name, doc
  
  &gt;&gt;&gt; function()
  "function", "Docstring"
  </code></pre>
  
  <p>What do I need to replace the question marks with so that I get the name and the docstring of the function from inside the same function?</p>
  
  <p>EDIT:
  Most of the answers so far explicitly hardcode the name of the function inside its definition. Is it possible do something like below where a new function get_name_doc would access the function from the outer frame from which it is called, and return its name and doc?</p>
  
  <pre><code>def get_name_doc():
      ???
  
  def function():
      "Docstring"
  
      name, doc = get_name_doc()
  
      return name, doc
  
  &gt;&gt;&gt; function()
  "function", "Docstring"
  </code></pre>