[Python-checkins] bpo-38524: clarify example a bit and improve formatting (GH-17406)

Miss Islington (bot) webhook-mailer at python.org
Thu Nov 28 00:29:06 EST 2019


https://github.com/python/cpython/commit/c0db88f6abbace79644b2aca2290bf41b1a37174
commit: c0db88f6abbace79644b2aca2290bf41b1a37174
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-11-27T21:29:02-08:00
summary:

bpo-38524: clarify example a bit and improve formatting (GH-17406)

(cherry picked from commit 02519f75d15b063914a11351da30178ca4ceb54b)

Co-authored-by: Tal Einat <taleinat+github at gmail.com>

files:
M Doc/reference/datamodel.rst

diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index ae24adeacb167..46d50ad600ff5 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -1657,13 +1657,16 @@ class' :attr:`~object.__dict__`.
 
    .. note::
 
-      ``__set_name__`` is only called implicitly as part of the ``type`` constructor, so
-      it will need to be called explicitly with the appropriate parameters when a
-      descriptor is added to a class after initial creation::
+      :meth:`__set_name__` is only called implicitly as part of the
+      :class:`type` constructor, so it will need to be called explicitly with
+      the appropriate parameters when a descriptor is added to a class after
+      initial creation::
 
+         class A:
+            pass
          descr = custom_descriptor()
-         cls.attr = descr
-         descr.__set_name__(cls, 'attr')
+         A.attr = descr
+         descr.__set_name__(A, 'attr')
 
       See :ref:`class-object-creation` for more details.
 



More information about the Python-checkins mailing list