From 40297fb9d4d80294f87137cf499cacf9113d9a50 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 00:29:57 -0800 Subject: [PATCH 1/9] Missing article --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index fedf8a8c09eac4..71680ccd6b6b4e 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -112,7 +112,7 @@ different, updated answers each time:: Besides showing how descriptors can run computations, this example also reveals the purpose of the parameters to :meth:`__get__`. The *self* parameter is *size*, an instance of *DirectorySize*. The *obj* parameter is -either *g* or *s*, an instance of *Directory*. It is *obj* parameter that +either *g* or *s*, an instance of *Directory*. It is the *obj* parameter that lets the :meth:`__get__` method learn the target directory. The *objtype* parameter is the class *Directory*. From ebf66173cb43210935cb8d043a14d691c2613872 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 00:39:29 -0800 Subject: [PATCH 2/9] Missing word --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index 71680ccd6b6b4e..23ef0bc00f179c 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -183,7 +183,7 @@ logged, but that the regular attribute *name* is not logged:: INFO:root:Accessing 'age' giving 40 40 -One major issue with this example is the private name *_age* is hardwired in +One major issue with this example is that the private name *_age* is hardwired in the *LoggedAgeAccess* class. That means that each instance can only have one logged attribute and that its name is unchangeable. In the next example, we'll fix that problem. From 8fb445a29cfc04adfd2390dcb1fad3dc414bf97e Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 00:41:31 -0800 Subject: [PATCH 3/9] s/what/which/ --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index 23ef0bc00f179c..a583959d9ddbc9 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -192,7 +192,7 @@ we'll fix that problem. Customized names ---------------- -When a class uses descriptors, it can inform each descriptor about what +When a class uses descriptors, it can inform each descriptor about which variable name was used. In this example, the :class:`Person` class has two descriptor instances, From 8eee012444a375611d028d6c4466cee441badb8f Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 00:44:12 -0800 Subject: [PATCH 4/9] Verb form of lookup --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index a583959d9ddbc9..e642810079b54c 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -233,7 +233,7 @@ be recorded, giving each descriptor its own *public_name* and *private_name*:: An interactive session shows that the :class:`Person` class has called :meth:`__set_name__` so that the field names would be recorded. Here -we call :func:`vars` to lookup the descriptor without triggering it:: +we call :func:`vars` to look up the descriptor without triggering it:: >>> vars(vars(Person)['name']) {'public_name': 'name', 'private_name': '_name'} From d6b77a6d90049632d1eebf19e6de67ed6aa462a2 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 01:01:06 -0800 Subject: [PATCH 5/9] Missing conjunction --- Doc/howto/descriptor.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index e642810079b54c..a96952ba0afb99 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -614,8 +614,8 @@ Sometimes it is desirable for a descriptor to know what class variable name it was assigned to. When a new class is created, the :class:`type` metaclass scans the dictionary of the new class. If any of the entries are descriptors and if they define :meth:`__set_name__`, that method is called with two -arguments. The *owner* is the class where the descriptor is used, the *name* -is class variable the descriptor was assigned to. +arguments. The *owner* is the class where the descriptor is used, and the +*name* is the class variable the descriptor was assigned to. The implementation details are in :c:func:`type_new()` and :c:func:`set_names()` in :source:`Objects/typeobject.c`. From 84e8e953df66c5d86e73f71b894dc64d06a571ac Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 01:07:35 -0800 Subject: [PATCH 6/9] only a single call is forwarded --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index a96952ba0afb99..875cf7c3497501 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -703,7 +703,7 @@ Properties ---------- Calling :func:`property` is a succinct way of building a data descriptor that -triggers function calls upon access to an attribute. Its signature is:: +triggers a function call upon access to an attribute. Its signature is:: property(fget=None, fset=None, fdel=None, doc=None) -> property From f7831f1fa9822d1f816e5a56a83112b5c27967eb Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 01:11:42 -0800 Subject: [PATCH 7/9] s/which/that/ --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index 875cf7c3497501..8d979839085bab 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -803,7 +803,7 @@ roughly equivalent to:: To support automatic creation of methods, functions include the :meth:`__get__` method for binding methods during attribute access. This -means that functions are non-data descriptors which return bound methods +means that functions are non-data descriptors that return bound methods during dotted lookup from an instance. Here's how it works:: class Function: From 3f329c589e6e20f160aac21c1bdea805915ab458 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 01:14:36 -0800 Subject: [PATCH 8/9] Missing article --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index 8d979839085bab..3a9c414520f691 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -1016,7 +1016,7 @@ attributes stored in ``__slots__``:: class Immutable: - __slots__ = ('_dept', '_name') # Replace instance dictionary + __slots__ = ('_dept', '_name') # Replace the instance dictionary def __init__(self, dept, name): self._dept = dept # Store to private attribute From ea5e51ab62077e20770a0c6d6d03665b29b2a455 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 6 Nov 2020 01:18:20 -0800 Subject: [PATCH 9/9] Correct an article --- Doc/howto/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst index 3a9c414520f691..8c2e8d562153db 100644 --- a/Doc/howto/descriptor.rst +++ b/Doc/howto/descriptor.rst @@ -1086,7 +1086,7 @@ by member descriptors:: The :meth:`type.__new__` method takes care of adding member objects to class variables. The :meth:`object.__new__` method takes care of creating instances -that have slots instead of a instance dictionary. Here is a rough equivalent +that have slots instead of an instance dictionary. Here is a rough equivalent in pure Python:: class Type(type):