In python3, you can use the __getattribute__
method. See following example with a list method name string:
func_name = 'reverse'l = [1, 2, 3, 4]print(l)>> [1, 2, 3, 4]l.__getattribute__(func_name)()print(l)>> [4, 3, 2, 1]
In python3, you can use the __getattribute__
method. See following example with a list method name string:
func_name = 'reverse'l = [1, 2, 3, 4]print(l)>> [1, 2, 3, 4]l.__getattribute__(func_name)()print(l)>> [4, 3, 2, 1]