Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
58c8f9f6
Commit
58c8f9f6
authored
Mar 28, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added documentation for PyObject_IsInstance() and PyObject_IsSubclass().
parent
fc369f21
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
Doc/api/api.tex
Doc/api/api.tex
+36
-0
No files found.
Doc/api/api.tex
View file @
58c8f9f6
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment