Iterators, iterables and special objects
Chris Angelico
rosuav at gmail.com
Thu Jul 23 04:41:16 EDT 2020
On Thu, Jul 23, 2020 at 5:55 PM Peter Slížik <peter.slizik at gmail.com> wrote:
> Moreover, some tutorial authors make it even more difficult with using the
> terms iterator and iterable interchangeably. A notorious example is this
> wiki:
> https://wiki.python.org/moin/Iterator
>
> It says:
>
> *Here is an *iterator* that returns a random number of 1's: *
>
> class RandomIterable: def __iter__(self): return self
>
BTW, that article had been written using the Python 2 syntax, with a
"next" function rather than "__next__". I've now updated it, so the
examples should work if copied and pasted into a current Python
interpreter.
ChrisA
More information about the Python-list
mailing list