MCPcopy Create free account
hub / github.com/numpy/numpy / formatargvalues

Function formatargvalues

numpy/_utils/_inspect.py:168–191  ·  view source on GitHub ↗

Format an argument spec from the 4 values returned by getargvalues. The first four arguments are (args, varargs, varkw, locals). The next four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is

(args, varargs, varkw, locals,
                    formatarg=str,
                    formatvarargs=lambda name: '*' + name,
                    formatvarkw=lambda name: '**' + name,
                    formatvalue=lambda value: '=' + repr(value),
                    join=joinseq)

Source from the content-addressed store, hash-verified

166 return '(' + ', '.join(specs) + ')'
167
168def formatargvalues(args, varargs, varkw, locals,
169 formatarg=str,
170 formatvarargs=lambda name: '*' + name,
171 formatvarkw=lambda name: '**' + name,
172 formatvalue=lambda value: '=' + repr(value),
173 join=joinseq):
174 """Format an argument spec from the 4 values returned by getargvalues.
175
176 The first four arguments are (args, varargs, varkw, locals). The
177 next four arguments are the corresponding optional formatting functions
178 that are called to turn names and values into strings. The ninth
179 argument is an optional function to format the sequence of arguments.
180
181 """
182 def convert(name, locals=locals,
183 formatarg=formatarg, formatvalue=formatvalue):
184 return formatarg(name) + formatvalue(locals[name])
185 specs = [strseq(arg, convert, join) for arg in args]
186
187 if varargs:
188 specs.append(formatvarargs(varargs) + formatvalue(locals[varargs]))
189 if varkw:
190 specs.append(formatvarkw(varkw) + formatvalue(locals[varkw]))
191 return '(' + ', '.join(specs) + ')'

Callers

nothing calls this directly

Calls 2

strseqFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected