+ 2
Nested function
how can I call a nested function from function that are out side of the main function def main() def a() def fun() def b() # do something # call function a
2 odpowiedzi
+ 1
since a() is a local function inside the main function, without using global functions i dont see any elegant way how you could run it from another function outside of the main function. But my solution would be:
def main(call_a = False):
def a():
print("hi")
if call_a is True:
a()
def func():
def b():
call_nested_func_inside_main = True
main(call_nested_func_inside_main)
b()
func()
So you call a nested function by using some arguments from the functions outside of the parent function.
0
I have follow up question what if both function are in class
the class as two nested function