Random832
Akira Li <4kir4.1i@gmail.com> writes:
3. Cannot accept an iterator (goes through it twice, or permanently stores a reference to it, etc) neither
*iterable* is an object that you can pass to iter() to get *iterator*. An iterable does not guarantee that it yields the same items twice.
True or false?: It is reasonable to write algorithms that iterate twice over a passed-in iterable, with the expectation that said iterable will typically be an object (or a view of such an object) which will not be concurrently modified (e.g. by a different thread or by a side-effect of a callback) during the execution of the algorithm, but which does not behave in a useful way when given an iterator, a generator, or any other kind of iterable which exhibits similar behavior whereby the second and further attempts to iterate will yield no items.
True or false?: do all iterables return the same items twice? http://www.fallacyfiles.org/loadques.html Specific application may use more specific requirements e.g.: list(iterable): - does it mean that all iterables must be finite? - do we need a special word to describe what list() accepts? set(iterable): - does it mean that all iterables must yield hashable items? - do we need a special word to describe what set() accepts? dict(iterable): - does it mean that all iterables must yield pairs? - do we need a special word to describe what dict() accepts? You've got the idea: the word *iterable* may be used in the context when not all iterables are accepted.