The following C function is used to convert the values contained in C variables to a Python object:
PyObject *Py_BuildValue(char *format, ...)
This constructs a Python object from a series of C variables. format is a string describing the desired conversion. The remaining arguments are the values of C variables to be converted.
The format specifier is similar to that used with the PyArg_ParseTuple* functions, as shown in Table 27.3.
|Format||Python Type||C Type||Description|
|“s”||String||char *||Null-terminated string. If the C string pointer is NULL,None is returned.|
|“s#”||String||char *, int||String and length. May contain null bytes. If the C string pointer is NULL, None is returned. ...|