'Given a function, returns a string representing its args.'

def _generate_signature_for_function(self, func):

    args_list = []
    argspec = inspect.getargspec(func)
    first_arg_with_default = (len((argspec.args or [])) - len((argspec.defaults or [])))
    for arg in argspec.args[:first_arg_with_default]:
        if (arg == 'self'):
            continue
        args_list.append(arg)
    if ((argspec.varargs == 'args') and (argspec.keywords == 'kwds')):
        original_func = func.__closure__[0].cell_contents
        return self._generate_signature_for_function(original_func)
    if argspec.defaults:
        for (arg, default) in zip(argspec.args[first_arg_with_default:], argspec.defaults):
            if callable(default):
                args_list.append(('%s=%s' % (arg, default.__name__)))
            else:
                args_list.append(('%s=%r' % (arg, default)))
    if argspec.varargs:
        args_list.append(('*' + argspec.varargs))
    if argspec.keywords:
        args_list.append(('**' + argspec.keywords))
    return (('(' + ',    '.join(args_list)) + ')')
