def formatargspec(args, varargs=None, varkw=None, defaults=None,<EOL>formatarg=str,<EOL>formatvarargs=lambda name: '<STR_LIT:*>' + name,<EOL>formatvarkw=lambda name: '<STR_LIT>' + name,<EOL>formatvalue=lambda value: '<STR_LIT:=>' + repr(value),<EOL>join=joinseq):
specs = []<EOL>if defaults:<EOL><INDENT>firstdefault = len(args) - len(defaults)<EOL><DEDENT>for i in range(len(args)):<EOL><INDENT>spec = strseq(args[i], formatarg, join)<EOL>if defaults and i >= firstdefault:<EOL><INDENT>spec = spec + formatvalue(defaults[i - firstdefault])<EOL><DEDENT>specs.append(spec)<EOL><DEDENT>if varargs is not None:<EOL><INDENT>specs.append(formatvarargs(varargs))<EOL><DEDENT>if varkw is not None:<EOL><INDENT>specs.append(formatvarkw(varkw))<EOL><DEDENT>return '<STR_LIT:(>' + '<STR_LIT:U+002CU+0020>'.join(specs) + '<STR_LIT:)>'<EOL>
Format an argument spec from the 4 values returned by getargspec.

    The first four arguments are (args, varargs, varkw, defaults).  The
    other four arguments are the corresponding optional formatting functions
    that are called to turn names and values into strings.  The ninth
    argument is an optional function to format the sequence of arguments.