I want to call 1 precise function in another function from another function
def exemple():
def dostuff1():
print('Stuff 1')
def dostuff2():
print('Stuff 2')
def dostuff3():
print('Stuff 3')
def training():
#want to call ONLY Dostuff2
Define your function example as this:-
def exemple(func_name):
def dostuff1():
print('Stuff 1')
def dostuff2():
print('Stuff 2')
def dostuff3():
print('Stuff 3')
func_dic = {
"dostuff1" : dostuff1,
"dostuff2" : dostuff2,
"dostuff3" : dostuff3
}
return func_dic[func_name]
Then call your function in the other function like this:
def training():
exemple("dostuff2")()
I hope it helps!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments