Python Get Function of Current Module by Name/String

April 24, 2019
func = locals().get("FUNCTION_NAME")
if func:
    func()

NOTE: locals()

Update and return a dictionary representing the current local symbol table. Free variables are returned by locals() when it is called in function blocks, but not in class blocks. Note that at the module level, locals() and globals() are the same dictionary.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.