Converting Data from Python to C
The following C functions are used to convert arguments passed from Python to C. Their prototypes are defined by including the Python.h header file.
int PyArg_ParseTuple(PyObject *args, char *format, ...);
Parses a tuple of objects in args into a series of C variables. format is a format string containing zero or more of the specifier strings from Table 27.1, which describes the expected contents of args. All the remaining arguments contain the addresses of C variables into which the results will be placed. The order and types of these arguments must match the specifiers used in format and use the C data types listed in Table 27.1. Zero is returned if the arguments could not be parsed.
int PyArg_ParseTupleAndKeywords(PyObject ...
Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.