diff options
author | Fred Drake <fdrake@acm.org> | 2001-03-28 21:14:32 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-03-28 21:14:32 (GMT) |
commit | 58c8f9f631090a2883744c07dce407eb87c265d3 (patch) | |
tree | 13d1e0ffd51c50c1abeb4fcb9979f66e08c1d121 /Doc | |
parent | fc369f21d5835574f8717a2a946b857edebecc24 (diff) | |
download | cpython-58c8f9f631090a2883744c07dce407eb87c265d3.zip cpython-58c8f9f631090a2883744c07dce407eb87c265d3.tar.gz cpython-58c8f9f631090a2883744c07dce407eb87c265d3.tar.bz2 |
Added documentation for PyObject_IsInstance() and PyObject_IsSubclass().
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/api/api.tex | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Doc/api/api.tex b/Doc/api/api.tex index 8bf0892..dfeb060 100644 --- a/Doc/api/api.tex +++ b/Doc/api/api.tex @@ -1493,6 +1493,42 @@ the equivalent of the Python expression \samp{unistr(\var{o})}. Called by the \function{unistr()}\bifuncindex{unistr} built-in function. \end{cfuncdesc} +\begin{cfuncdesc}{int}{PyObject_IsInstance}{PyObject *inst, PyObject *cls} +Return \code{1} if \var{inst} is an instance of the class \var{cls} or +a subclass of \var{cls}. If \var{cls} is a type object rather than a +class object, \cfunction{PyObject_IsInstance()} returns \code{1} if +\var{inst} is of type \var{cls}. If \var{inst} is not a class +instance and \var{cls} is neither a type object or class object, +\var{inst} must have a \member{__class__} attribute --- the class +relationship of the value of that attribute with \var{cls} will be +used to determine the result of this function. +\versionadded{2.1} +\end{cfuncdesc} + +Subclass determination is done in a fairly straightforward way, but +includes a wrinkle that implementors of extensions to the class system +may want to be aware of. If \class{A} and \class{B} are class +objects, \class{B} is a subclass of \class{A} if it inherits from +\class{A} either directly or indirectly. If either is not a class +object, a more general mechanism is used to determine the class +relationship of the two objects. When testing if \var{B} is a +subclass of \var{A}, if \var{A} is \var{B}, +\cfunction{PyObject_IsSubclass()} returns true. If \var{A} and +\var{B} are different objects, \var{B}'s \member{__bases__} attribute +is searched in a depth-first fashion for \var{A} --- the presence of +the \member{__bases__} attribute is considered sufficient for this +determination. + +\begin{cfuncdesc}{int}{PyObject_IsSubclass}{PyObject *derived, + PyObject *cls} +Returns \code{1} if the class \var{derived} is identical to or derived +from the class \var{cls}, otherwise returns \code{0}. In case of an +error, returns \code{-1}. If either \var{derived} or \var{cls} is not +an actual class object, this function uses the generic algorithm +described above. +\versionadded{2.1} +\end{cfuncdesc} + \begin{cfuncdesc}{int}{PyCallable_Check}{PyObject *o} Determine if the object \var{o} is callable. Return \code{1} if the |