开发者

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

开发者 https://www.devze.com 2023-03-12 07:24 出处:网络
Example (builtinmodule.c): static PyObject * builtin___import__(PyObject *self, PyObject *args, PyObject *kwds)

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 ca开发者_JAVA百科llable PyObject was a function: PyString_AsString(PyObject_GetAttrString(func, "__name__"))), but I don't know what attributes to look for in the args.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消