Number of arguments in python functions

Max Source

I am writing a code which embeds python C API, and I need to know the number of arguments of a function before calling it. I found a solution which involves callyng __code__ and co_argcount through PyObject_GetAttrString(), but is seems not all functions have these attributes (eg. built-in functions). Is there another way to achieve the same result, possibly using as less as possible PyImport_Import() or PyObject_CallObject()?



comments powered by Disqus