Answers for "python3 call class method by name"

1

python execute function from string

import foo
method_to_call = getattr(foo, 'bar')
result = method_to_call()
Posted by: Guest on April-07-2020
-1

python get function from string name

module = __import__('foo')
func = getattr(module, 'bar')
func()
Posted by: Guest on June-25-2020

Code answers related to "python3 call class method by name"

Python Answers by Framework

Browse Popular Code Answers by Language