9
.. c:function:: int PyMapping_Check(PyObject *o)
11
Return ``1`` if the object provides mapping protocol, and ``0`` otherwise. This
12
function always succeeds.
15
.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o)
16
Py_ssize_t PyMapping_Length(PyObject *o)
18
.. index:: builtin: len
20
Returns the number of keys in object *o* on success, and ``-1`` on failure. For
21
objects that do not provide mapping protocol, this is equivalent to the Python
22
expression ``len(o)``.
25
.. c:function:: int PyMapping_DelItemString(PyObject *o, const char *key)
27
Remove the mapping for object *key* from the object *o*. Return ``-1`` on
28
failure. This is equivalent to the Python statement ``del o[key]``.
31
.. c:function:: int PyMapping_DelItem(PyObject *o, PyObject *key)
33
Remove the mapping for object *key* from the object *o*. Return ``-1`` on
34
failure. This is equivalent to the Python statement ``del o[key]``.
37
.. c:function:: int PyMapping_HasKeyString(PyObject *o, const char *key)
39
On success, return ``1`` if the mapping object has the key *key* and ``0``
40
otherwise. This is equivalent to the Python expression ``key in o``.
41
This function always succeeds.
44
.. c:function:: int PyMapping_HasKey(PyObject *o, PyObject *key)
46
Return ``1`` if the mapping object has the key *key* and ``0`` otherwise. This
47
is equivalent to the Python expression ``key in o``. This function always
51
.. c:function:: PyObject* PyMapping_Keys(PyObject *o)
53
On success, return a list, a tuple or a dictionary view in case of a dict,
54
of the keys in object *o*. On failure, return *NULL*.
57
.. c:function:: PyObject* PyMapping_Values(PyObject *o)
59
On success, return a list, a tuple or a dictionary view in case of a dict, of
60
the values in object *o*. On failure, return *NULL*.
63
.. c:function:: PyObject* PyMapping_Items(PyObject *o)
65
On success, return a list, a tuple or a dictionary view in case of a dict, of
66
the items in object *o*, where each item is a tuple containing a key-value
67
pair. On failure, return *NULL*.
70
.. c:function:: PyObject* PyMapping_GetItemString(PyObject *o, const char *key)
72
Return element of *o* corresponding to the object *key* or *NULL* on failure.
73
This is the equivalent of the Python expression ``o[key]``.
76
.. c:function:: int PyMapping_SetItemString(PyObject *o, const char *key, PyObject *v)
78
Map the object *key* to the value *v* in object *o*. Returns ``-1`` on failure.
79
This is the equivalent of the Python statement ``o[key] = v``.