> Imagine an altenative universe where a south african programmer called > Rossu van Guidom writes a wonderful language called Mamba and in that > language iterator semantics are defined like this: > > * Objects that wish to be iterable define an __iter__() method returning an > iterator. > > * An iterator is an object with a next() method. That's all. But that doesn't allow for things like file objects, which, although not iterators themselves, are capable of producing iterators of different sorts which iterate over them in different ways -- and yet they can only be iterated over once. In other words, there are such things as one-shot iterables, even if iterables and iterators are kept separate. Maybe a one-shot iterable should raise an exception if you try to obtain a second iterator from it? Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+
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