From e0054c51c7337354e415deb5b1a3d17778f42b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Araujo?= Date: Fri, 19 Aug 2011 09:15:47 +0200 Subject: [PATCH] Link isinstance/issubclass to the ABC glossary entry (#12256) --- Doc/glossary.rst | 5 ++++- Doc/library/functions.rst | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 41228cd0e09..37fa9b02174 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -30,7 +30,10 @@ Glossary Abstract base classes complement :term:`duck-typing` by providing a way to define interfaces when other techniques like :func:`hasattr` would be clumsy or subtly wrong (for example with - :ref:`magic methods `). Python comes with many built-in ABCs for + :ref:`magic methods `). ABCs introduce virtual + subclasses, which are classes that don't inherit from a class but are + still recognized by :func:`isinstance` and :func:`issubclass`; see the + :mod:`abc` module documentation. Python comes with many built-in ABCs for data structures (in the :mod:`collections` module), numbers (in the :mod:`numbers` module), and streams (in the :mod:`io` module). You can create your own ABCs with the :mod:`abc` module. diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index e31dff8f84c..a5dacc68dcb 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -624,9 +624,11 @@ available. They are listed here in alphabetical order. .. function:: isinstance(object, classinfo) Return true if the *object* argument is an instance of the *classinfo* argument, - or of a (direct or indirect) subclass thereof. Also return true if *classinfo* + or of a (direct, indirect or :term:`virtual `) subclass + thereof. Also return true if *classinfo* is a type object (new-style class) and *object* is an object of that type or of - a (direct or indirect) subclass thereof. If *object* is not a class instance or + a (direct, indirect or :term:`virtual `) subclass + thereof. If *object* is not a class instance or an object of the given type, the function always returns false. If *classinfo* is neither a class object nor a type object, it may be a tuple of class or type objects, or may recursively contain other such tuples (other sequence types are @@ -639,7 +641,8 @@ available. They are listed here in alphabetical order. .. function:: issubclass(class, classinfo) - Return true if *class* is a subclass (direct or indirect) of *classinfo*. A + Return true if *class* is a subclass (direct, indirect or :term:`virtual + `) of *classinfo*. A class is considered a subclass of itself. *classinfo* may be a tuple of class objects, in which case every entry in *classinfo* will be checked. In any other case, a :exc:`TypeError` exception is raised.