codehaus


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Iterators, iterables and special objects


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