Working on some python code for some automation around the house and had the need to be able to pass dictionary object to a function name that was dynamically generated by the input to the script.
Normally this is simple using the xmlrpclib module that you can install for python. All you need to do is pass in the dictionary object into the function and make sure that the function that you write on the XMLRPC server is looking for a dictionary object.
This is how you would pass in a dictionary object to a known XMLRPC function:
s = xmlrpclib.ServerProxy('http://localhost:8000')
dictionary = []
api_call = s.function(dictionary)
return api_call
When you don’t know the function name it is recommended that you use the getattr method as it is quicker, but you cannot pass in a dictionary object into it. So the only solution I found to do this is to use the eval method in the way I did bellow:
s = xmlrpclib.ServerProxy('http://localhost:8000')
dictionary = []
function = 'function name'
api_call = eval('s.%s(dictionary)' % function)
return api_call
I would love to hear any improvements to the way I am doing this if you have any. Please leave a comment.

