I was studying about inner functions. One of its uses is in closure and factory functions.
Consider the following example I found here
def generate_power(number):
"""
Examples of use:
>>> raise_two = generate_power(2)
>>> raise_three = generate_power(3)
>>> print(raise_two(7))
128
>>> 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
If I were to run the use case from this example, it would create a new function raise_two.
Can we print function definition of raise_two? (making it easier to understand the whole concept)
edit:
This question requires an answer that is different from the ones found at How can I get the source code of a Python function? as I've explained in the comment section.