Search code examples
pythonpython-2.6cpython

How do I read the arguments in "args" passed to a builtin function in Python [source]?


Example (builtinmodule.c):

static PyObject *
builtin___import__(PyObject *self, PyObject *args, PyObject *kwds)
{
    ...
}

How do I go about getting the arguments, args, in string format? I believe it would be similar to finding the name of a function (if a callable PyObject was a function: PyString_AsString(PyObject_GetAttrString(func, "__name__"))), but I don't know what attributes to look for in the args.


Solution

  • The easiest thing to do is just get the repr of the object, since it's a tuple.