Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'say,': 0.05; 'none.': 0.09; 'subject:while': 0.09; 'value.': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.17; 'received:209.85.214.174': 0.21; '15,': 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'andrew': 0.27; 'converting': 0.27; 'message-id:@mail.gmail.com': 0.27; 'starts': 0.29; 'point': 0.31; 'values.': 0.33; 'to:addr:python-list': 0.33; 'languages': 0.33; 'received:google.com': 0.34; 'or,': 0.34; 'false': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'skip:u 10': 0.60; 'jul': 0.65; 'treat': 0.65; 'fact,': 0.69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=OoufxCeS9YPi4JdXEXW0CAhM2uEUxj0q6SfBuJYbVS8=; b=Fx2RUEd5bzdO+sqJokZZ397IjsZQh/ORoaILcwDrNSMOYFxGWV3y+roJN38jraFCci zGQfzTGP7ex5rmOYNwPcOLypItdvV5TrfdLWMMFq8p1LLETVPQ/lJjg0BdOnO6OnDxnc 2TPVbfZ94fLG5sdh7ywX0/pzAxKVhRbQtHH9sGquGLrvFNABvorvPTUjePd0w/wR6Rgv VsTnWxpT2ZYSsMWiJ5Pa83sK1CeEu28UhW3j3M9kGb/SMNKyASLEK8zVloiHabEHeiHm HHzic1DoDVCDKM1Wuch2YWRnDxkCBRbHyed9fhnSslMjk3I3JV82tZ5weCB/JAhUz8KQ hgCQ== MIME-Version: 1.0 In-Reply-To: <500280A6.6070608@gmail.com> References: <500280A6.6070608@gmail.com> Date: Sun, 15 Jul 2012 18:47:05 +1000 Subject: Re: Implicit conversion to boolean in if and while statements From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342342029 news.xs4all.nl 6938 [2001:888:2000:d::a6]:45593 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25343 On Sun, Jul 15, 2012 at 6:34 PM, Andrew Berg wrote: > Converting 0 and 1 to False and True seems reasonable, but I don't see > the point in converting other arbitrary values. It's for convenience. Unfortunately, not all languages treat all types the same way. It's very handy, though, to be able to use if not foo: foo = some_initializer when foo starts out as, say, None. Or []. Or, in fact, any other "empty" value. ChrisA