On Sat, 28 Oct 2006 11:42:42 +0200, Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Steven > D'Aprano wrote: > >> On Fri, 27 Oct 2006 11:25:09 -0700, Carl Banks wrote: >> >>> Iterators do have overlapping uses with lists, but the "if a:" doesn't >>> work for them, so it's moot. >> >> Sure it works for iterators. >> >>>>> it = iter([0]) >>>>> bool(it) >> True >>>>> it.next() >> 0 >>>>> bool(it) >> False > > It works for *this* iterator. By accident.
Blimey, you're right. That can't be good. In fact, it made a certain BDFL pretty mad: http://mail.python.org/pipermail/python-dev/2005-September/056594.html Okay, so all iterators are intentionally *supposed* to be True, always, even if they are exhausted. As Guido says, don't treat iterators as containers. Fair enough. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list