def formatargvalues(args, varargs, varkw, locals, formatarg=str, formatvarargs=(lambda name: ('*' + name)), formatvarkw=(lambda name: ('**' + name)), formatvalue=(lambda value: ('=' + repr(value))), join=joinseq):
 def convert(name, locals=locals, formatarg=formatarg, formatvalue=formatvalue):
  return (formatarg(name) + formatvalue(locals[name]))
 specs = []
 for i in range(len(args)):
  specs.append(strseq(args[i], convert, join))
 if varargs:
  specs.append((formatvarargs(varargs) + formatvalue(locals[varargs])))
 if varkw:
  specs.append((formatvarkw(varkw) + formatvalue(locals[varkw])))
 return (('(' + string.join(specs, ', ')) + ')')

def formatargvalues ( args , varargs , varkw , locals , formatarg = str , formatvarargs = ( lambda name : ( '*' + name ) ) , formatvarkw = ( lambda name : ( '**' + name ) ) , formatvalue = ( lambda value : ( '=' + repr ( value ) ) ) , join = joinseq ) : def convert ( name , locals = locals , formatarg = formatarg , formatvalue = formatvalue ) : return ( formatarg ( name ) + formatvalue ( locals [ name ] ) ) specs = [ ] for i in range ( len ( args ) ) : specs . append ( strseq ( args [ i ] , convert , join ) ) if varargs : specs . append ( ( formatvarargs ( varargs ) + formatvalue ( locals [ varargs ] ) ) ) if varkw : specs . append ( ( formatvarkw ( varkw ) + formatvalue ( locals [ varkw ] ) ) ) return ( ( '(' + string . join ( specs , ', ' ) ) + ')' )
format an argument spec from the 4 values returned by getargvalues .