call a function inside another function python code example
Example 1: nested functions in python
def print_msg(msg):
# This is the outer enclosing function
def printer():
# This is the nested function
print(msg)
return printer # returns the nested function
# Now let's try calling this function.
# Output: Hello
another = print_msg("Hello")
another()
Example 2: call a function from another class python
class A:
def method1(arg1, arg2):
# do code here
class B:
A.method1(1,2)