Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16205 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2011-11-25 19:46 +1100 |
| Last post | 2011-11-25 19:46 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Strange result ffor object to bool Chris Angelico <rosuav@gmail.com> - 2011-11-25 19:46 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-11-25 19:46 +1100 |
| Subject | Re: Strange result ffor object to bool |
| Message-ID | <mailman.3029.1322210780.27778.python-list@python.org> |
On Fri, Nov 25, 2011 at 5:52 PM, ZhouPeng <zpengxen@gmail.com> wrote:
> I am sure listen is not None and can be accessed properly.
>
> But print bool(listen) is False
> if not listen is True
Casting something to boolean follows strict rules derived from the
notion that emptiness is false and nonemptiness is true. For instance:
>>> bool(""),bool([]),bool({}),bool(0)
(False, False, False, False)
Details here: http://docs.python.org/library/stdtypes.html
Chris Angelico
Back to top | Article view | comp.lang.python
csiph-web