def formatArgValues(args, varargs, varkw, localsDict, formatarg=str,
    formatvarargs=lambda name: '*' + name, formatvarkw=lambda name: '**' +
    name, formatvalue=lambda value: '=' + repr(value)):
    """Formats an argument spec from the 4 values returned by getArgValues"""
    specs = []
    for i in range(len(args)):
        name = args[i]
        specs.append(formatarg(name) + formatvalue(localsDict[name]))
    if varargs:
        specs.append(formatvarargs(varargs) + formatvalue(localsDict[varargs]))
    if varkw:
        specs.append(formatvarkw(varkw) + formatvalue(localsDict[varkw]))
    argvalues = '(' + ', '.join(specs) + ')'
    if '__return__' in localsDict:
        argvalues += ' -> ' + formatvalue(localsDict['__return__'])
    return argvalues
