[Python-Dev] bool(iter([])) changed between 2.3 and 2.4

Guido van Rossum guido at python.org
Tue Sep 20 23:49:41 CEST 2005


I just finished debugging some code that broke after upgrading to
Python 2.4 (from 2.3). Turns out the code was testing list iterators
for their boolean value (to distinguish them from None). In 2.3, a
list iterator (like any iterator) is always true. In 2.4, an exhausted
list iterator is false; probably by virtue of having a __len__()
method that returns the number of remaining items.

I realize that this was a deliberate feature, and that it exists in
2.4 as well as in 2.4.1 and will in 2.4.2; yet, I'm not sure I *like*
it. Was this breakage (which is not theoretical!) considered at all?

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list