From 6218295388b488109e05165ebfa367c08e155c49 Mon Sep 17 00:00:00 2001 From: alclarks Date: Fri, 15 Nov 2019 20:00:11 +0000 Subject: [PATCH 1/3] Sequence documentation cleanups --- Doc/reference/datamodel.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 2499aeb6996bb1c..72886c34cdde0fc 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1566,7 +1566,7 @@ not found on a module object through the normal lookup, i.e. the module ``__dict__`` before raising an :exc:`AttributeError`. If found, it is called with the attribute name and the result is returned. -The ``__dir__`` function should accept no arguments, and return a list of +The ``__dir__`` function should accept no arguments, and return a sequence of strings that represents the names accessible on module. If present, this function overrides the standard :func:`dir` search on a module. @@ -1797,6 +1797,10 @@ Notes on using *__slots__* (the other bases must have empty slot layouts) - violations raise :exc:`TypeError`. +* If an iterator is used for *__slots__* then a descriptor is created for each + of the iterator's values. However, the *__slots__* variable will be an empty + iterator. + .. _class-customization: Customizing class creation @@ -2128,8 +2132,8 @@ operators. It is recommended that both mappings and sequences implement the mappings, ``in`` should search the mapping's keys; for sequences, it should search through the values. It is further recommended that both mappings and sequences implement the :meth:`__iter__` method to allow efficient iteration -through the container; for mappings, :meth:`__iter__` should be the same as -:meth:`keys`; for sequences, it should iterate through the values. +through the container; for mappings, :meth:`__iter__` should return an iterator +through the object's keys; for sequences, it should iterate through the values. .. method:: object.__len__(self) @@ -2243,9 +2247,9 @@ through the container; for mappings, :meth:`__iter__` should be the same as The membership test operators (:keyword:`in` and :keyword:`not in`) are normally -implemented as an iteration through a sequence. However, container objects can +implemented as an iteration through a container. However, container objects can supply the following special method with a more efficient implementation, which -also does not require the object be a sequence. +also does not require the object be iterable. .. method:: object.__contains__(self, item) From c874858cb93a52880da2e4f754eef6b4e6eb3e48 Mon Sep 17 00:00:00 2001 From: alclarks <57201106+alclarks@users.noreply.github.com> Date: Fri, 15 Nov 2019 20:51:21 +0000 Subject: [PATCH 2/3] Update Doc/reference/datamodel.rst Change "variable" for "attribute" Co-Authored-By: Brandt Bucher --- Doc/reference/datamodel.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 72886c34cdde0fc..a76ecaebbbc5d80 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1798,7 +1798,7 @@ Notes on using *__slots__* :exc:`TypeError`. * If an iterator is used for *__slots__* then a descriptor is created for each - of the iterator's values. However, the *__slots__* variable will be an empty + of the iterator's values. However, the *__slots__* attribute will be an empty iterator. .. _class-customization: From 1f1559cceb24bb2c079a619253ef16c5f51e468c Mon Sep 17 00:00:00 2001 From: alclarks <57201106+alclarks@users.noreply.github.com> Date: Fri, 15 Nov 2019 20:52:50 +0000 Subject: [PATCH 3/3] Update Doc/reference/datamodel.rst Tweak for readability Co-Authored-By: Brandt Bucher --- Doc/reference/datamodel.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index a76ecaebbbc5d80..76b7035ced97944 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2132,7 +2132,7 @@ operators. It is recommended that both mappings and sequences implement the mappings, ``in`` should search the mapping's keys; for sequences, it should search through the values. It is further recommended that both mappings and sequences implement the :meth:`__iter__` method to allow efficient iteration -through the container; for mappings, :meth:`__iter__` should return an iterator +through the container; for mappings, :meth:`__iter__` should iterate through the object's keys; for sequences, it should iterate through the values. .. method:: object.__len__(self)