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.
This is an example of the use of this function, taken from the sources for the _weakref helper module for weak references:
static PyObject * weakref_ref(PyObject *self, PyObject *args) { PyObject *object; PyObject *callback = NULL; PyObject *result = NULL; if (PyArg_UnpackTuple(args, "ref", 1, 2, &object, &callback)) { result = PyWeakref_NewRef(object, callback); } return result; }
The call to PyArg_UnpackTuple() in this example is entirely equivalent to this call to PyArg_ParseTuple():
PyArg_ParseTuple(args, "O|O:ref", &object, &callback)
New in version 2.2.