Did I find the right examples for you? yes no

All Samples(100)  |  Call(82)  |  Derive(0)  |  Import(18)
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.

        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('{!r} is not a code object'.format(co))

    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)
        


src/d/j/django-admin-report-HEAD/example/lib/reportlab/graphics/shapes.py   django-admin-report(Download)
        if I: _addObjImport(self,I)
        if isinstance(self,Shape):
            from inspect import getargs
            args, varargs, varkw = getargs(self.__init__.im_func.func_code)
            P = self.getProperties()

src/p/l/plexnet-HEAD/source/plexnet/util/secure26.py   plexnet(Download)
    if not inspect.isfunction(func):
        raise TypeError('arg is not a Python function')
    args, varargs, varkw = inspect.getargs(sys.get_func_code(func))
    return inspect.ArgSpec(args, varargs, varkw, func.func_defaults)
 

src/p/l/plexnet-HEAD/source/plexnet/util/secure25.py   plexnet(Download)
    if not inspect.isfunction(func):
        raise TypeError('arg is not a Python function')
    args, varargs, varkw = inspect.getargs(sys.get_func_code(func))
    return args, varargs, varkw, func.func_defaults
 

src/s/a/sage-HEAD/src/sage/misc/sageinspect.py   sage(Download)
    # Otherwise we're (hopefully!) plain Python, so use inspect
    try:
        args, varargs, varkw = inspect.getargs(func_obj.__code__)
    except AttributeError:
        try:
            args, varargs, varkw = inspect.getargs(func_obj)

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/IPython/core/oinspect.py   antisocial(Download)
    else:
        raise TypeError('arg is not a Python function')
    args, varargs, varkw = inspect.getargs(func_obj.func_code)
    return args, varargs, varkw, func_obj.func_defaults
 

src/k/u/kuma-lib-HEAD/packages/ipython/IPython/OInspect.py   kuma-lib(Download)
    else:
        raise TypeError, 'arg is not a Python function'
    args, varargs, varkw = inspect.getargs(func_obj.func_code)
    return args, varargs, varkw, func_obj.func_defaults
 

src/s/p/spyderlib-mirror-HEAD/spyderlib/utils/dochelpers.py   spyderlib-mirror(Download)
            # Example: PyQt4
            return getargsfromdoc(obj)
    args, _, _ = inspect.getargs(func_obj.func_code)
    if not args:
        return getargsfromdoc(obj)

src/p/r/prymatex-HEAD/prymatex/utils/dochelpers.py   prymatex(Download)
            # Example: PyQt4
            return getargsfromdoc(obj)
    args, _, _ = inspect.getargs(func_obj.__code__)
    if not args:
        return getargsfromdoc(obj)

src/l/u/luminoso-HEAD/luminoso/lib/spyderlib/utils/dochelpers.py   luminoso(Download)
        # Builtin: try to extract info from getdoc
        return getargfromdoc(func_obj)
    args, _, _ = inspect.getargs(func_obj.func_code)
    if not args:
        return getargfromdoc(obj)

src/m/a/mayavi-4.3.1/tvtk/tools/tvtk_doc.py   mayavi(Download)
    else:
        return ''
    args, vargs, vkw = inspect.getargs(func_obj.func_code)
    defaults = func_obj.func_defaults
    doc = fname + inspect.formatargspec(args, vargs, vkw, defaults)

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8  Next