title: Is there a programmatic way to print the definition of a dynamically created function in python?
body: <p>I was studying about <em>inner functions</em>. One of its uses is in closure and factory functions.</p>
  
  <p>Consider the following example I found <a href="https://realpython.com/blog/python/inner-functions-what-are-they-good-for/" rel="nofollow noreferrer">here</a></p>
  
  <pre><code>def generate_power(number):
      """
      Examples of use:
  
      &gt;&gt;&gt; raise_two = generate_power(2)
      &gt;&gt;&gt; raise_three = generate_power(3)
      &gt;&gt;&gt; print(raise_two(7))
      128
      &gt;&gt;&gt; print(raise_three(5))
      243
      """
  
      # define the inner function ...
      def nth_power(power):
          return number ** power
      # ... which is returned by the factory function
  
      return nth_power
  </code></pre>
  
  <p>If I were to run the use case from this example, it would create a new function <strong>raise_two</strong>.</p>
  
  <p>Can we print function definition of <strong>raise_two</strong>? (making it easier to understand the whole concept)</p>
  
  <p><strong>edit:</strong></p>
  
  <p>This question requires an answer that is different from the ones found at <a href="https://stackoverflow.com/questions/427453/how-can-i-get-the-source-code-of-a-python-function">How can I get the source code of a Python function?</a> as I've explained in the comment section.</p>