On 9/22/05, Jim Jewett <[EMAIL PROTECTED]> wrote:
> "Is there anything left?" is a pretty analogy for iterators,
But unmaintainable for iterators in general. This was considered ad
nauseam when iterators were initially introduced, and it was an
explicit decision *not* to provide an API to look ahead.
We should *not* give people a way to start coding like this:
while it:
x = it.next()
...process x...
when they should be writing this instead:
for x in it:
...process x...
How would you implement the "is there anything left" functionality if
the iterator is in fact a generator? (I know, the answer is buffering.
But that has problems too. It was all considered when we designed it.)
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com