my_args = {'name': 'Jim', 'age': 30, 'country': 'France'} getattr(web, 'input')(**my_args)
You also don't need to use getattr, you can just call the method directly (if you don't want to search for an attribute from a string):
web.input(**my_args)
You can do the same with lists:
my_args_list = ['Jim', 30, 'A cool person'] getattr(web, 'input')(*my_args_list)
equivalently
getattr(web, 'input')('Jim', 30, 'A cool person')
source share