See also
,
and
.
intPyMapping_Check(
*o)
Part of the
.Return 1 if the object provides the mapping protocol or supports slicing, and 0 otherwise. Note that it returns 1 for Python classes with a
method, since in general it is impossible to determine what type of keys the class supports. This function always succeeds.
PyMapping_Size(
*o)
PyMapping_Length(
*o)
Part of the
.Returns the number of keys in object o on success, and -1 on failure. This is equivalent to the Python expression len(o).
*PyMapping_GetItemString(
*o, constchar*key)
Return value: New reference. Part of the
.This is the same as
, but key is specified as a constchar* UTF-8 encoded bytes string, rather than a
*.
intPyMapping_GetOptionalItem(
*obj,
*key,
**result)
Part of the
since version 3.13.Variant of
which doesn’t raise
if the key is not found.
If the key is found, return 1 and set *result to a new
to the corresponding value. If the key is not found, return 0 and set *result to NULL; the
is silenced. If an error other than KeyError is raised, return -1 and set *result to NULL.
Added in version 3.13.
intPyMapping_GetOptionalItemString(
*obj, constchar*key,
**result)
Part of the
since version 3.13.This is the same as
, but key is specified as a constchar* UTF-8 encoded bytes string, rather than a
*.
Added in version 3.13.
intPyMapping_SetItemString(
*o, constchar*key,
*v)
Part of the
.This is the same as
, but key is specified as a constchar* UTF-8 encoded bytes string, rather than a
*.
intPyMapping_DelItem(
*o,
*key)
This is an alias of
.
intPyMapping_DelItemString(
*o, constchar*key)
This is the same as
, but key is specified as a constchar* UTF-8 encoded bytes string, rather than a
*.
intPyMapping_HasKeyWithError(
*o,
*key)
Part of the
since version 3.13.Return 1 if the mapping object has the key key and 0 otherwise. This is equivalent to the Python expression keyino. On failure, return -1.
Added in version 3.13.
intPyMapping_HasKeyStringWithError(
*o, constchar*key)
Part of the
since version 3.13.This is the same as
, but key is specified as a constchar* UTF-8 encoded bytes string, rather than a
*.
Added in version 3.13.
intPyMapping_HasKey(
*o,
*key)
Part of the
.Return 1 if the mapping object has the key key and 0 otherwise. This is equivalent to the Python expression keyino. This function always succeeds.
intPyMapping_HasKeyString(
*o, constchar*key)
Part of the
.This is the same as
, but key is specified as a constchar* UTF-8 encoded bytes string, rather than a
*.
Note
Exceptions that occur when this calls the
method or while creating the temporary
object are silently ignored. For proper error handling, use
PyMapping_HasKeyStringWithError()
,
PyMapping_GetOptionalItemString()
or
instead.
*PyMapping_Keys(
*o)
Return value: New reference. Part of the
.On success, return a list of the keys in object o. On failure, return NULL.
Changed in version 3.7: Previously, the function returned a list or a tuple.
*PyMapping_Values(
*o)
Return value: New reference. Part of the
.On success, return a list of the values in object o. On failure, return NULL.
Changed in version 3.7: Previously, the function returned a list or a tuple.
*PyMapping_Items(
*o)
Return value: New reference. Part of the
.On success, return a list of the items in object o, where each item is a tuple containing a key-value pair. On failure, return NULL.
Changed in version 3.7: Previously, the function returned a list or a tuple.