while true: !!!
Alex Martelli
aleaxit at yahoo.com
Tue Dec 19 05:10:30 EST 2000
"Rainer Deyke" <root at rainerdeyke.com> wrote in message
news:KTz%5.48644$x6.22165257 at news2.rdc2.tx.home.com...
> "Steve Lamb" <grey at despair.rpglink.com> wrote in message
> news:slrn93t7bv.le.grey at teleute.rpglink.com...
> > On Mon, 18 Dec 2000 23:32:23 +0100 (MET), Carsten Geckeler
> <nospam at no.spam>
> > wrote:
> > >`while true' would be more readable and clear than `while 1'. By the
> way,
> > >explain a newbie that -1 is true. ;)
> >
> > 0 is true, all else is false. And? :P
>
> 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...
Alex
More information about the Python-list
mailing list