O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required