while true: !!!

Steven D. Majewski sdm7g at virginia.edu
Tue Dec 19 12:44:46 EST 2000

On Tue, 19 Dec 2000, Carsten Geckeler wrote:

> > > 0 is false, None is false, [] is false, () is false, {} is false, and x is
> > > false where x is a class instance and x.__nonzero__() returns false.
> > > Everything else is true.  I think.
> > 
> > Another couple of 'false's: a class instance which doesn't define
> > __nonzero__ but does define __length__ when the latter returns 0;
> > and, C-implemented user objects, similarly to class instances.
> > 
> > I don't _think_ there are any more...
> Nice; It takes three tries of -- I assume -- experienced Python
> programmers to find all cases of all statements evaluating as false. ;)

No: There's an infinite number of statements that evaluate to false in
Python (and in all programming languages for that matter!) so don't
wait for someone to come along and iterate them all for you. I don't
think they were trying to find them all -- they were trying to classify
them all. 

-- Steve Majewski <sdm7g at Virginia.EDU> 

More information about the Python-list mailing list