5.5 Parsing arguments and building values

These functions are useful when creating your own extensions functions and methods. Additional information and examples are available in Extending and Embedding the Python Interpreter.

int PyArg_ParseTuple(PyObject *args, char *format, ...)
Parse the parameters of a function that takes only positional parameters into local variables. Returns true on success; on failure, it returns false and raises the appropriate exception. See Extending and Embedding the Python Interpreter for more information.

int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, char *format, char *keywords[], ...)
Parse the parameters of a function that takes both positional and keyword parameters into local variables. Returns true on success; on failure, it returns false and raises the appropriate exception. See Extending and Embedding the Python Interpreter for more information.

int PyArg_Parse(PyObject *args, char *format, ...)
Function used to deconstruct the argument lists of ``old-style'' functions -- these are functions which use the METH_OLDARGS parameter parsing method. This is not recommended for use in parameter parsing in new code, and most code in the standard interpreter has been modified to no longer use this for that purpose. It does remain a convenient way to decompose other tuples, however, and may continue to be used for that purpose.

PyObject* Py_BuildValue(char *format, ...)
Return value: New reference.
Create a new value based on a format string similar to those accepted by the PyArg_Parse*() family of functions 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. For more information on the format string and additional parameters, see Extending and Embedding the Python Interpreter.
See About this document... for information on suggesting changes.