parameters: (co)
return_statement: return Arguments(args, varargs, varkw)
docstring: Get information about the arguments accepted by a code object.
  
      Three things are returned: (args, varargs, varkw), where 'args' is
      a list of argument names (possibly containing nested lists), and
      'varargs' and 'varkw' are the names of the * and ** arguments or None.
docstring_summary: Get information about the arguments accepted by a code object.
docstring_tokens: Get information about the arguments accepted by a code object .
function: def getargs(co):
      """Get information about the arguments accepted by a code object.
  
      Three things are returned: (args, varargs, varkw), where 'args' is
      a list of argument names (possibly containing nested lists), and
      'varargs' and 'varkw' are the names of the * and ** arguments or None."""
  
      if not iscode(co):
          raise TypeError('arg is not a code object')
  
      nargs = co.co_argcount
      names = co.co_varnames
      args = list(names[:nargs])
      step = 0
  
      # The following acrobatics are for anonymous (tuple) arguments.
      for i in range(nargs):
          if args[i][:1] in ('', '.'):
              stack, remain, count = [], [], []
              while step < len(co.co_code):
                  op = ord(co.co_code[step])
                  step = step + 1
                  if op >= dis.HAVE_ARGUMENT:
                      opname = dis.opname[op]
                      value = ord(co.co_code[step]) + ord(co.co_code[step+1])*256
                      step = step + 2
                      if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'):
                          remain.append(value)
                          count.append(value)
                      elif opname == 'STORE_FAST':
                          stack.append(names[value])
  
                          # Special case for sublists of length 1: def foo((bar))
                          # doesn't generate the UNPACK_TUPLE bytecode, so if
                          # `remain` is empty here, we have such a sublist.
                          if not remain:
                              stack[0] = [stack[0]]
                              break
                          else:
                              remain[-1] = remain[-1] - 1
                              while remain[-1] == 0:
                                  remain.pop()
                                  size = count.pop()
                                  stack[-size:] = [stack[-size:]]
                                  if not remain: break
                                  remain[-1] = remain[-1] - 1
                              if not remain: break
              args[i] = stack[0]
  
      varargs = None
      if co.co_flags & CO_VARARGS:
          varargs = co.co_varnames[nargs]
          nargs = nargs + 1
      varkw = None
      if co.co_flags & CO_VARKEYWORDS:
          varkw = co.co_varnames[nargs]
      return Arguments(args, varargs, varkw)
function_tokens: def getargs ( co ) : if not iscode ( co ) : raise TypeError ( 'arg is not a code object' ) nargs = co . co_argcount names = co . co_varnames args = list ( names [ : nargs ] ) step = 0 # The following acrobatics are for anonymous (tuple) arguments. for i in range ( nargs ) : if args [ i ] [ : 1 ] in ( '' , '.' ) : stack , remain , count = [ ] , [ ] , [ ] while step < len ( co . co_code ) : op = ord ( co . co_code [ step ] ) step = step + 1 if op >= dis . HAVE_ARGUMENT : opname = dis . opname [ op ] value = ord ( co . co_code [ step ] ) + ord ( co . co_code [ step + 1 ] ) * 256 step = step + 2 if opname in ( 'UNPACK_TUPLE' , 'UNPACK_SEQUENCE' ) : remain . append ( value ) count . append ( value ) elif opname == 'STORE_FAST' : stack . append ( names [ value ] ) # Special case for sublists of length 1: def foo((bar)) # doesn't generate the UNPACK_TUPLE bytecode, so if # `remain` is empty here, we have such a sublist. if not remain : stack [ 0 ] = [ stack [ 0 ] ] break else : remain [ - 1 ] = remain [ - 1 ] - 1 while remain [ - 1 ] == 0 : remain . pop ( ) size = count . pop ( ) stack [ - size : ] = [ stack [ - size : ] ] if not remain : break remain [ - 1 ] = remain [ - 1 ] - 1 if not remain : break args [ i ] = stack [ 0 ] varargs = None if co . co_flags & CO_VARARGS : varargs = co . co_varnames [ nargs ] nargs = nargs + 1 varkw = None if co . co_flags & CO_VARKEYWORDS : varkw = co . co_varnames [ nargs ] return Arguments ( args , varargs , varkw )