Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'none,': 0.05; '"if': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'semantics': 0.09; 'subject:while': 0.09; 'terry': 0.09; 'journey.': 0.16; 'message-id:@dough.gmane.org': 0.16; 'none"': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'record,': 0.16; 'reedy': 0.16; 'tables,': 0.16; 'trap': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'explicit': 0.22; '15,': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'right.': 0.27; 'header:X-Complaints-To:1': 0.28; "d'aprano": 0.29; 'steven': 0.29; 'objects': 0.29; 'point': 0.31; 'to:addr:python-list': 0.33; "can't": 0.34; 'done': 0.34; 'false': 0.35; 'pm,': 0.35; 'received:org': 0.36; 'test': 0.36; 'should': 0.36; '(for': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'end': 0.40; 'think': 0.40; 'ever': 0.63; 'behavior': 0.64; 'jul': 0.65; 'ago.': 0.66; 'believe': 0.69; '(is': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Implicit conversion to boolean in if and while statements Date: Sun, 15 Jul 2012 16:09:44 -0400 References: <5002a1f9$0$29995$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342382996 news.xs4all.nl 6898 [2001:888:2000:d::a6]:44805 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25372 On 7/15/2012 12:19 PM, Ian Kelly wrote: > On Sun, Jul 15, 2012 at 4:56 AM, Steven D'Aprano > wrote: >> (For the record, I can only think of one trap for the unwary: time >> objects are false at *exactly* midnight.) > > Ugh, that's irritating. I can't think of any scenario where I would > ever want the semantics "if timeval (is not midnight):". This When printing time tables, midnight may be either 24:00 or 0:00, depending on whether it is the end or start of a journey. That could, of course, be done by explicit if time == midnight: rather than if not time:. Whether to change the current behavior was discussed on python-ideas a couple of months ago. I believe inertia and back-compatibity and the rare use case won. > reinforces the point that if you only want to test whether you have > None, you should use "is not None" rather than relying on __bool__. Right. -- Terry Jan Reedy