result = 'function (%s)' % ', '.join(map(str,args))
I recommend the map(str, args) instead of just args because some of your arguments could potentially not be strings and would cause a TypeError, for example, with an int argument in your list:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected string, int found
When you get into dict objects you will probably want to comma-separate the values of the dict (presumably because the values are what you want to pass into this function). If you do the join method on the dict object itself, you will get the keys separated, like so:
>>> d = {'d':5, 'f':6.0, 'r':"BOB"}
>>> ','.join(d)
'r,d,f'
What you want is the following:
>>> d = {'d':5, 'f':6.0, 'r':"BOB"}
>>> result = 'function (%s)' % ', '.join(map(str, d.values()))
>>> result
'function (BOB, 5, 6.0)'
Note the new problem you encounter, however. When you pass a string argument through the join function, it loses its quoting. So if you planned to pass strings through, you have lost the quotes that usually would surround the string when passed into a function (strings are quoted in many general-purpose languages). If you're only passing numbers, however, this isn't a problem for you.
There is probably a nicer way of solving the problem I just described, but here's one method that could work for you.
>>> l = list()
>>> for val in d.values():
... try:
... v = float(val) #half-decent way of checking if something is an int, float, boolean
... l.append(val) #if it was, then append the original type to the list
... except:
... #wasn't a number, assume it's a string and surround with quotes
... l.append("\"" + val + "\"")
...
>>> result = 'function (%s)' % ', '.join(map(str, l))
>>> result
'function ("BOB", 5, 6.0)'
Now the string has quotes surrounding itself. If you are passing more complex types than numeric primitives and strings then you probably need a new question :)
One last note: I have been using d.values() to show how to extract the values from a dictionary, but in fact that will return the values from the dictionary in pretty much arbitrary order. Since your function most likely requires the arguments in a particular order, you should manually construct your list of values instead of calling d.values().