Let's say I have a module fibo, and it has a function whose name contains a string “baz”. How do I call this function?.
The following code should call the required function
import fibo result = getattr(fibo, 'baz') print result
Similarly we can use getattr class instance bound methods, module-level methods, class methods and so on.
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more