MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / getargs

Function getargs

tools/python-3.11.9-amd64/Lib/inspect.py:1301–1326  ·  view source on GitHub ↗

Get information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is the list of argument names. Keyword-only arguments are appended. 'varargs' and 'varkw' are the names of the * and ** arguments or None.

(co)

Source from the content-addressed store, hash-verified

1299Arguments = namedtuple('Arguments', 'args, varargs, varkw')
1300
1301def getargs(co):
1302 """Get information about the arguments accepted by a code object.
1303
1304 Three things are returned: (args, varargs, varkw), where
1305 'args' is the list of argument names. Keyword-only arguments are
1306 appended. 'varargs' and 'varkw' are the names of the * and **
1307 arguments or None."""
1308 if not iscode(co):
1309 raise TypeError('{!r} is not a code object'.format(co))
1310
1311 names = co.co_varnames
1312 nargs = co.co_argcount
1313 nkwargs = co.co_kwonlyargcount
1314 args = list(names[:nargs])
1315 kwonlyargs = list(names[nargs:nargs+nkwargs])
1316 step = 0
1317
1318 nargs += nkwargs
1319 varargs = None
1320 if co.co_flags & CO_VARARGS:
1321 varargs = co.co_varnames[nargs]
1322 nargs = nargs + 1
1323 varkw = None
1324 if co.co_flags & CO_VARKEYWORDS:
1325 varkw = co.co_varnames[nargs]
1326 return Arguments(args + kwonlyargs, varargs, varkw)
1327
1328
1329FullArgSpec = namedtuple('FullArgSpec',

Callers 1

getargvaluesFunction · 0.85

Calls 3

iscodeFunction · 0.85
listFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected