What values are considered false?

Grant Edwards grante at visi.com
Wed Feb 20 22:05:49 EST 2002


In article <e9e6dd1f.0202201727.9741615 at posting.google.com>, Jason wrote:

> In my experimentation 0, None, "", [], and () all seem to be
> considered false.

Yup.  It seems odd, but once you get the hang of it, it's *so*
useful.

> Just to confound me none of them are == to each other.

Likewise, all non-false things need not be == to each other.

> Coming from a Scheme world this is confusing.  Are there any
> other values that are false?  Why aren't () and "" the same thing?

Because they're not.  ;)

One is a string, the other is a tuple.  They are objects of
different types.

> Don't both describe an immutable sequence of values (basically, why
> aren't strings either lists or tuples)?

Mostly because it is both useful that way and I suspect easier
to impliment.  Two of the interesting features of strings is
that strings are always flat (they don't nest), and for
non-empty strings type(s) == type(s[0]).

-- 
Grant Edwards                   grante             Yow!  Clear the
                                  at               laundromat!! This
                               visi.com            whirl-o-matic just had a
                                                   nuclear meltdown!!



More information about the Python-list mailing list