File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -535,7 +535,10 @@ Glossary
535535 iterables include all sequence types (such as :class: `list `, :class: `str `,
536536 and :class: `tuple `) and some non-sequence types like :class: `dict `,
537537 :term: `file objects <file object> `, and objects of any classes you define
538- with an :meth: `__iter__ ` or :meth: `__getitem__ ` method. Iterables can be
538+ with an :meth: `__iter__ ` method or with a :meth: `__getitem__ ` method
539+ that implements :term: `Sequence ` semantics.
540+
541+ Iterables can be
539542 used in a :keyword: `for ` loop and in many other places where a sequence is
540543 needed (:func: `zip `, :func: `map `, ...). When an iterable object is passed
541544 as an argument to the built-in function :func: `iter `, it returns an
Original file line number Diff line number Diff line change @@ -107,7 +107,12 @@ ABC Inherits from Abstract Methods Mixin
107107.. class :: Iterable
108108
109109 ABC for classes that provide the :meth: `__iter__ ` method.
110- See also the definition of :term: `iterable `.
110+
111+ Checking ``isinstance(obj, Iterable) `` detects classes that are registered
112+ as :class: `Iterable ` or that have an :meth: `__iter__ ` method, but it does
113+ not detect classes that iterate with the :meth: `__getitem__ ` method.
114+ The only reliable way to determine whether an object is :term: `iterable `
115+ is to call ``iter(obj) ``.
111116
112117.. class :: Collection
113118
You can’t perform that action at this time.
0 commit comments