On 2005 Jan 16, at 03:17, Phillip J. Eby wrote: ... > Uh oh. I just used "view" to describe an iterator as a view on an > iterable, as distinct from an adapter that adapts a sequence so that > it's iterable. :) > > I.e., using "view" in the MVC sense where a given Model might have > multiple independent Views. I think that in order to do that you need to draw a distinction between two categories of iterables: so, again, a problem of terminology, but one connected to a conceptual difference. An iterator IS-AN iterable: it has __iter__. However, it can't have "multiple independent views"... except maybe if you use itertools.tee for that purpose. Other iterables are, well, ``re-iterables'': each call to their __iter__ makes a new fresh iterator, and using that iterator won't alter the iterable's state. In this case, viewing multiple iterators on the same re-iterables as akin to views on a model seems quite OK. I can't think of any 3rd case -- an iterable that's not an iterator (__iter__ does not return self) but neither is it seamlessly re-iterable. Perhaps the ``file'' built-in type as it was in 2.2 suffered that problem, but it was a design problem, and is now fixed. Alex
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