On Tue, Oct 13, 2015 at 10:26 AM, Random832 <random832 at fastmail.com> wrote: > "R. David Murray" <rdmurray at bitdance.com> writes: > >> On Tue, 13 Oct 2015 14:59:56 +0300, Stefan Mihaila >> <stefanmihaila91 at gmail.com> wrote: >>> Maybe it's just python2 habits, but I assume I'm not the only one >>> carelessly thinking that "iterating over an input a second time will >>> result in the same thing as the first time (or raise an error)". >> >> This is the way iterators have always worked. > > It does raise the question though of what working code it would actually > break to have "exhausted" iterators raise an error if you try to iterate > them again rather than silently yield no items. You mean like this? >>> m = map(int, '1234') >>> list(m) [1, 2, 3, 4] >>> next(m) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration It just happens that 'list()' and 'for ...' handle StopIteration for you. -- Zach
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