Strange result ffor object to bool
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Nov 25 03:59:41 EST 2011
On Fri, 25 Nov 2011 14:52:25 +0800, ZhouPeng wrote:
> Hi all,
>
> In my program, I get a listen element by listen =
> graphics.find("listen")
What is a listen element? It is not a standard Python object. What
library is it from?
> print listen is <Element listen at 6afc20> print type listen is <type
> 'instance'> I am sure listen is not None and can be accessed properly.
>
> But print bool(listen) is False
What makes you think this is a strange result? Many things are false:
py> for obj in (None, [], {}, 0, 0.0, "", 42):
... print bool(obj),
...
False False False False False False True
--
Steven
More information about the Python-list
mailing list