Quantcast
Channel: Calling a function of a module by using its name (a string) - Stack Overflow
Viewing all articles
Browse latest Browse all 22

Answer by JeffUK for Calling a function of a module by using its name (a string)

$
0
0

In many, many use cases, the answer is 'Don't!'

Instead do something like:

safe_functions = {'baz':foo.baz, 'bar':foo.bar}safe_functions['bar']()safe_functions['delete_all_the_things']() 

Viewing all articles
Browse latest Browse all 22

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>