how can I convert a dictionary to a string of keyword arguments?
The same syntax is used to accept arbitrary keyword arguments.
Python 2:
def somestring(**kwargs):
return ', '.join('%s=%r' % x for x in kwargs.iteritems())
Python 3:
def somestring(**kwargs):
return ", ".join(f"{key}={value}" for key, value in kwargs.items())
Note that dicts are arbitrarily ordered, so the resultant string may be in a different order than the arguments passed.