From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 25 Sep 2017 07:57:24 +0000 (-0700) Subject: [3.6] bpo-18558: Clarify glossary entry for "Iterable" (GH-3732) (#3741) X-Git-Tag: v3.6.4rc1~226 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=01438ed4c22ca150da1cc5c38d83a59b0b6a62a7;p=python [3.6] bpo-18558: Clarify glossary entry for "Iterable" (GH-3732) (#3741) (cherry picked from commit 0bf287b6e0a42877b06cbea5d0fe6474d8061caa) --- diff --git a/Doc/glossary.rst b/Doc/glossary.rst index dba9186d93..b947520b96 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -535,7 +535,10 @@ Glossary iterables include all sequence types (such as :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence types like :class:`dict`, :term:`file objects `, and objects of any classes you define - with an :meth:`__iter__` or :meth:`__getitem__` method. Iterables can be + with an :meth:`__iter__` method or with a :meth:`__getitem__` method + that implements :term:`Sequence` semantics. + + Iterables can be used in a :keyword:`for` loop and in many other places where a sequence is needed (:func:`zip`, :func:`map`, ...). When an iterable object is passed as an argument to the built-in function :func:`iter`, it returns an diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst index 58b03b9bd7..6015453209 100644 --- a/Doc/library/collections.abc.rst +++ b/Doc/library/collections.abc.rst @@ -107,7 +107,12 @@ ABC Inherits from Abstract Methods Mixin .. class:: Iterable ABC for classes that provide the :meth:`__iter__` method. - See also the definition of :term:`iterable`. + + Checking ``isinstance(obj, Iterable)`` detects classes that are registered + as :class:`Iterable` or that have an :meth:`__iter__` method, but it does + not detect classes that iterate with the :meth:`__getitem__` method. + The only reliable way to determine whether an object is :term:`iterable` + is to call ``iter(obj)``. .. class:: Collection