What values are considered false?
Bernhard Herzog
bh at intevation.de
Thu Feb 21 07:30:56 EST 2002
scarblac at pino.selwerd.nl (Remco Gerlich) writes:
> Jason <caljason76 at yahoo.com> wrote in comp.lang.python:
> > In my experimentation 0, None, "", [], and () all seem to be
> > considered false. Just to confound me none of them are == to each
> > other. Coming from a Scheme world this is confusing. Are there any
> > other values that are false?
>
> {}, at least. Any classes that return the right results on certain special
> functions (__nonzero__(), if I remember correctly).
or __len__ if __nonzero__ isn't defined.
> > Why aren't () and "" the same thing?
>
> Because one is an empty tuple and one is an empty string.
Plus they're not equal or identical in scheme either, at least not in
guile:
guile> (equal? "" ())
#f
guile> (eq? "" ())
#f
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
MapIt! http://mapit.de/
More information about the Python-list
mailing list