First page Back Continue Last page Overview Image

Py_BuildValue

Py_BuildValue("i", result);

PyObject* Py_BuildValue(const char *format, ...)

Return value: New reference.

Create a new value based on a format string and a sequence of values. Returns the value or NULL in the case of an error; an exception will be raised if NULL is returned.

Py_BuildValue does not always build a tuple. It builds a tuple only if its format string contains two or more format units. If the format string is empty, it returns None; if it contains exactly one format unit, it returns whatever object is described by that format unit. To force it to return a tuple of size 0 or one, parenthesize the format string.