How can I call an inner function within a Python module?
I have created a Python module. Within this module, there is a function. Within this function, there is a nested function. I saved the Python file with the name custom_module.py.
I have then called this module using the statement import custom_module
.
I have then tried to call the nested function. I did this using the statement custom_module.outer_function().inner_module()
.
This has not called the function correctly. How could I call the inner function from within a Python module, or will I need to create separate functions and not use nested functions.
I do not always want to call the inner functions when I run the outer function.
An example of a file named module.py:
def outerFunction():
print("This is the outer function")
def innerFunction():
print("This is the inner function")
An example of the main file:
import module
module.outerFunction().innerFunction()