Python

Sentinel objects

PyTypeObject PySentinel_Type

PyTypeObject\의 인스턴스는 Python sentinel\ 타입을 나타냅니다. 이것은 sentinel\과 동일한 객체입니다.

Added in version 3.15.

int PySentinel_Check(PyObject *o)

o\가 sentinel\ 객체이거나 서브타입인지 true를 반환합니다. sentinel\ 타입은 현재 서브클래스를 허용하지 않으므로 이 확인은 정확합니다. 미래의 Python 버전에서는 서브타이핑을 허용할 수도 있습니다. 이 함수는 항상 성공합니다.

Added in version 3.15.

int PySentinel_CheckExact(PyObject *o)

Return true if o is a sentinel object, but not a subtype. The sentinel type does not currently allow subclasses. Future Python versions may choose to allow subtyping. This function always succeeds.

Added in version 3.15.

PyObject *PySentinel_New(const char *name, const char *module_name, const char *repr)
반환값: 새 참조.

Return a new sentinel object with __name__ set to name and __module__ set to module_name. name must not be NULL. If module_name is NULL, __module__ is set to None. If repr is NULL, repr() returns __name__. Return NULL with an exception set on failure.

픽클링 작업을 수행하려면, module_name\은 가져올 수 있는 모듈의 이름이어야 하며, 해당 sentinel은 name\과 일치하는 경로로 그 모듈에서 접근할 수 있어야 합니다. Pickle은 name\을 module_name\의 전역 변수 이름으로 간주합니다 ( object.__reduce__()\ 참조).

Added in version 3.15.