Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:object': 0.07; 'derived': 0.09; 'false,': 0.09; 'properly.': 0.09; '25,': 0.12; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'boolean': 0.16; 'emptiness': 0.16; 'false)': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instance:': 0.16; 'subject:result': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'header:In-Reply-To:1': 0.22; 'message-id:@mail.gmail.com': 0.28; 'print': 0.29; 'nov': 0.29; 'pm,': 0.29; 'chris': 0.30; 'skip:b 30': 0.31; 'url:library': 0.31; 'fri,': 0.34; 'rules': 0.34; 'to:addr:python-list': 0.34; 'something': 0.35; 'url:python': 0.36; 'none': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; 'details': 0.65; 'here:': 0.66; 'casting': 0.84; 'notion': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=BN5o7snaYqlhct/ZDK80I446+SgGIcwKwpxmaN8hWAU=; b=btZcCdTN2yIDp7HzCqtIje18/8lyqC7goJ70e1ID4rj9osNEvTM0aJ4yWzCRNVM9BT +3dlBPKR9rTaSfWk0U7jaeJ4+iyJV3vQNuuSBYlLEPL4j4dI/PkINAqqNGCMzLQRAjOO mq2swvOxo+ISuVEj3Wt+ZJQMb2TGR8GmknX/s= MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 25 Nov 2011 19:46:17 +1100 Subject: Re: Strange result ffor object to bool From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322210780 news.xs4all.nl 6908 [2001:888:2000:d::a6]:45539 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16205 On Fri, Nov 25, 2011 at 5:52 PM, ZhouPeng wrote: > I am sure listen is not None and can be accessed properly. > > But print bool(listen) is False > if not listen =A0is 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