Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'test,': 0.04; 'cpython': 0.05; 'bool': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subclass': 0.09; 'wrote:': 0.15; '"small"': 0.16; 'caches': 0.16; 'constants': 0.16; 'documented.': 0.16; 'expr': 0.16; 'pm,': 0.16; 'int': 0.19; 'true,': 0.19; 'header:In-Reply-To:1': 0.22; 'does': 0.32; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; 'test': 0.34; 'things': 0.34; 'subject:new': 0.36; 'anything': 0.37; 'but': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'sense': 0.40; 'prove': 0.64; '12:39': 0.84; '-->': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: NoneType and new instances Date: Sat, 30 Jul 2011 23:34:11 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 206.205.249.126 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312083252 news.xs4all.nl 23908 [2001:888:2000:d::a6]:40860 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10613 On 7/30/2011 12:39 PM, bruno.desthuilliers@gmail.com wrote: > On 28 juil, 17:39, Ethan Furman wrote: >> >> --> bool(0) is bool(0) >> True > This test is not reliable It is in the sense that it will always work -- because False/True are doubletone constants and so documented. But expr is expr == True does not reliably say it will always be true, because > - a same id can be reused for terms (I have > already seen such things happening). If you want a reliable test, use: > > #> a = bool(0) > #> b = bool(0) > #> a is b > True > > Note that this still fails to prove anything since bool is a subclass > of int and CPython caches "small" integers: > > #> a = 42 > #> b = 42 > #> a is b > True