Skip to content

Commit 8031877

Browse files
authored
Minor grammar edits for the descriptor howto guide (GH-#23175)
1 parent bde33e4 commit 8031877

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Doc/howto/descriptor.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ different, updated answers each time::
112112
Besides showing how descriptors can run computations, this example also
113113
reveals the purpose of the parameters to :meth:`__get__`. The *self*
114114
parameter is *size*, an instance of *DirectorySize*. The *obj* parameter is
115-
either *g* or *s*, an instance of *Directory*. It is *obj* parameter that
115+
either *g* or *s*, an instance of *Directory*. It is the *obj* parameter that
116116
lets the :meth:`__get__` method learn the target directory. The *objtype*
117117
parameter is the class *Directory*.
118118

@@ -183,7 +183,7 @@ logged, but that the regular attribute *name* is not logged::
183183
INFO:root:Accessing 'age' giving 40
184184
40
185185

186-
One major issue with this example is the private name *_age* is hardwired in
186+
One major issue with this example is that the private name *_age* is hardwired in
187187
the *LoggedAgeAccess* class. That means that each instance can only have one
188188
logged attribute and that its name is unchangeable. In the next example,
189189
we'll fix that problem.
@@ -192,7 +192,7 @@ we'll fix that problem.
192192
Customized names
193193
----------------
194194

195-
When a class uses descriptors, it can inform each descriptor about what
195+
When a class uses descriptors, it can inform each descriptor about which
196196
variable name was used.
197197

198198
In this example, the :class:`Person` class has two descriptor instances,
@@ -233,7 +233,7 @@ be recorded, giving each descriptor its own *public_name* and *private_name*::
233233

234234
An interactive session shows that the :class:`Person` class has called
235235
:meth:`__set_name__` so that the field names would be recorded. Here
236-
we call :func:`vars` to lookup the descriptor without triggering it::
236+
we call :func:`vars` to look up the descriptor without triggering it::
237237

238238
>>> vars(vars(Person)['name'])
239239
{'public_name': 'name', 'private_name': '_name'}
@@ -614,8 +614,8 @@ Sometimes it is desirable for a descriptor to know what class variable name it
614614
was assigned to. When a new class is created, the :class:`type` metaclass
615615
scans the dictionary of the new class. If any of the entries are descriptors
616616
and if they define :meth:`__set_name__`, that method is called with two
617-
arguments. The *owner* is the class where the descriptor is used, the *name*
618-
is class variable the descriptor was assigned to.
617+
arguments. The *owner* is the class where the descriptor is used, and the
618+
*name* is the class variable the descriptor was assigned to.
619619

620620
The implementation details are in :c:func:`type_new()` and
621621
:c:func:`set_names()` in :source:`Objects/typeobject.c`.
@@ -703,7 +703,7 @@ Properties
703703
----------
704704

705705
Calling :func:`property` is a succinct way of building a data descriptor that
706-
triggers function calls upon access to an attribute. Its signature is::
706+
triggers a function call upon access to an attribute. Its signature is::
707707

708708
property(fget=None, fset=None, fdel=None, doc=None) -> property
709709

@@ -803,7 +803,7 @@ roughly equivalent to::
803803

804804
To support automatic creation of methods, functions include the
805805
:meth:`__get__` method for binding methods during attribute access. This
806-
means that functions are non-data descriptors which return bound methods
806+
means that functions are non-data descriptors that return bound methods
807807
during dotted lookup from an instance. Here's how it works::
808808

809809
class Function:
@@ -1016,7 +1016,7 @@ attributes stored in ``__slots__``::
10161016

10171017
class Immutable:
10181018

1019-
__slots__ = ('_dept', '_name') # Replace instance dictionary
1019+
__slots__ = ('_dept', '_name') # Replace the instance dictionary
10201020

10211021
def __init__(self, dept, name):
10221022
self._dept = dept # Store to private attribute
@@ -1086,7 +1086,7 @@ by member descriptors::
10861086

10871087
The :meth:`type.__new__` method takes care of adding member objects to class
10881088
variables. The :meth:`object.__new__` method takes care of creating instances
1089-
that have slots instead of a instance dictionary. Here is a rough equivalent
1089+
that have slots instead of an instance dictionary. Here is a rough equivalent
10901090
in pure Python::
10911091

10921092
class Type(type):

0 commit comments

Comments
 (0)