+ 1

Is there a way to use dictionary mapping to get methods invoked?

DICTIONARY python

17th Aug 2020, 5:58 PM
HARIKRISHNAN L R
HARIKRISHNAN L R - avatar
4 Answers
+ 2
The same as you would with any dictionary https://code.sololearn.com/cq12Bd2tgatz/?ref=app
17th Aug 2020, 7:17 PM
Steven M
Steven M - avatar
0
Yes { "Name": function(*args,**kwargs) } you can store many functions this way and then iterate through them, or call them by their key
17th Aug 2020, 6:06 PM
Steven M
Steven M - avatar
0
What if this DICTIONARY needs to be accessed inside the if main ==" __main__ "? example: cmd_dict = {'play song': music()} ..................... ............. ...... if main ==" __main__":
17th Aug 2020, 6:13 PM
HARIKRISHNAN L R
HARIKRISHNAN L R - avatar
0
Thanks
18th Aug 2020, 4:40 AM
HARIKRISHNAN L R
HARIKRISHNAN L R - avatar