매핑 프로토콜¶
PyObject_GetItem(), PyObject_SetItem() 및 PyObject_DelItem()도 참조하십시오.
-
int PyMapping_Check(PyObject *o)¶
- Part of the 안정 ABI.
객체가 매핑 프로토콜을 제공하거나 슬라이싱을 지원하면
1을 반환하고, 그렇지 않으면0을 반환합니다.__getitem__()메서드가 있는 파이썬 클래스의 경우1을 반환한다는 점에 유의하십시오; 일반적으로 클래스가 지원하는 키 형을 판단할 수 없기 때문입니다. 이 함수는 항상 성공합니다.
-
Py_ssize_t PyMapping_Size(PyObject *o)¶
-
Py_ssize_t PyMapping_Length(PyObject *o)¶
- Part of the 안정 ABI.
성공 시 객체 o의 키 수를 반환하고, 실패하면
-1을 반환합니다. 이는 파이썬 표현식len(o)와 동등합니다.
-
PyObject *PyMapping_GetItemString(PyObject *o, const char *key)¶
- 반환값: 새 참조. Part of the 안정 ABI.
This is the same as
PyObject_GetItem(), but key is specified as a const char* UTF-8 encoded bytes string, rather than a PyObject*.
-
int PyMapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result)¶
- Part of the 안정 ABI 버전 3.13 이후로.
Variant of
PyObject_GetItem()which doesn’t raiseKeyErrorif the key is not found.If the key is found, return
1and set *result to a new strong reference to the corresponding value. If the key is not found, return0and set *result toNULL; theKeyErroris silenced. If an error other thanKeyErroris raised, return-1and set *result toNULL.Added in version 3.13.
-
int PyMapping_GetOptionalItemString(PyObject *obj, const char *key, PyObject **result)¶
- Part of the 안정 ABI 버전 3.13 이후로.
This is the same as
PyMapping_GetOptionalItem(), but key is specified as a const char* UTF-8 encoded bytes string, rather than a PyObject*.Added in version 3.13.
-
int PyMapping_SetItemString(PyObject *o, const char *key, PyObject *v)¶
- Part of the 안정 ABI.
This is the same as
PyObject_SetItem(), but key is specified as a const char* UTF-8 encoded bytes string, rather than a PyObject*.
-
int PyMapping_DelItem(PyObject *o, PyObject *key)¶
이것은
PyObject_DelItem()의 별칭입니다.
-
int PyMapping_DelItemString(PyObject *o, const char *key)¶
This is the same as
PyObject_DelItem(), but key is specified as a const char* UTF-8 encoded bytes string, rather than a PyObject*.
-
int PyMapping_HasKeyWithError(PyObject *o, PyObject *key)¶
- Part of the 안정 ABI 버전 3.13 이후로.
매핑 객체에 key 키가 있으면
1을 반환하고, 그렇지 않으면0을 반환합니다. 이는 파이썬 표현식key in o와 동등합니다. 실패하면-1을 반환합니다.Added in version 3.13.
-
int PyMapping_HasKeyStringWithError(PyObject *o, const char *key)¶
- Part of the 안정 ABI 버전 3.13 이후로.
This is the same as
PyMapping_HasKeyWithError(), but key is specified as a const char* UTF-8 encoded bytes string, rather than a PyObject*.Added in version 3.13.
-
int PyMapping_HasKey(PyObject *o, PyObject *key)¶
- Part of the 안정 ABI.
매핑 객체에 key 키가 있으면
1을 반환하고, 그렇지 않으면0을 반환합니다. 이는 파이썬 표현식key in o와 동등합니다. 이 함수는 항상 성공합니다.참고
Exceptions which occur when this calls the
__getitem__()method are silently ignored. For proper error handling, usePyMapping_HasKeyWithError(),PyMapping_GetOptionalItem()orPyObject_GetItem()instead.
-
int PyMapping_HasKeyString(PyObject *o, const char *key)¶
- Part of the 안정 ABI.
This is the same as
PyMapping_HasKey(), but key is specified as a const char* UTF-8 encoded bytes string, rather than a PyObject*.참고
Exceptions that occur when this calls the
__getitem__()method or while creating the temporarystrobject are silently ignored. For proper error handling, usePyMapping_HasKeyStringWithError(),PyMapping_GetOptionalItemString()orPyMapping_GetItemString()instead.
-
PyObject *PyMapping_Keys(PyObject *o)¶
- 반환값: 새 참조. Part of the 안정 ABI.
성공하면, 객체 o의 키 리스트를 반환합니다. 실패하면,
NULL을 반환합니다.버전 3.7에서 변경: 이전에는 함수가 리스트나 튜플을 반환했습니다.