From b9aa8cb0c7fe20472627312b713dd426ea4228cf Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 8 Apr 2014 12:04:04 -0400 Subject: [PATCH] docs: Document __objclass__. Closes #19281. Initial patch by Nick Coghlan --- Doc/reference/datamodel.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 8204dc3dcdc..a78b222a287 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1467,6 +1467,14 @@ class' :attr:`__dict__`. Called to delete the attribute on an instance *instance* of the owner class. +The :attr:`__objclass__` is interpreted by the :mod:`inspect` module as +specifying the class where this object was defined (setting this appropriately +can assist in runtime introspection of dynamic class attributes). For callables, +it may indicate that an instance of the given type (or a subclass) is expected +or required as the first positional argument (for example, CPython sets this +attribute for unbound methods that are implemented in C). + + .. _descriptor-invocation: Invoking Descriptors