Converting Data from Python to C

The following functions are used to convert arguments passed from Python to C.

					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 B.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 datatypes listed in Table B.1. Zero is returned if the arguments could not be parsed.

					int PyArg_ParseTupleAndKeywords(PyObject *
					args, PyObject *
					char *
					format, char ** ...

Get Python Essential Reference, Second 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.