A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-July/026321.html below:

[Python-Dev] Single- vs. Multi-pass iterability

[Python-Dev] Single- vs. Multi-pass iterability [Python-Dev] Single- vs. Multi-pass iterabilityGuido van Rossum guido@python.org
Fri, 12 Jul 2002 08:57:14 -0400
> If you put a next method on an iterable you are most probably
> confusing iterators and iterables and not just using the name 'next'
> for some other innocent purpose.

Quite to the contrary.  You might have a multi-iterable class that was
defined before the iterator protocol existed, and had a "built-in"
iterator that keeps the iteration state in the object itself (a common
design, e.g. BSD db files have this).  This is OK for simple uses.
But with iterators available the class might grow a proper iterator
class that keeps state external from the object.  But for backward
compatibility reasons you cannot remove the next() method on the class
itself.

QED: you have a multi-iterable object that has both an __iter__ method
and a next method.

--Guido van Rossum (home page: http://www.python.org/~guido/)




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4