Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: Operator Precedence/Boolean Logic Date: Thu, 23 Jun 2016 11:01:18 +0200 Lines: 37 Message-ID: References: <15997174-44d5-431c-8f90-a8d700921820@googlegroups.com> <56ecacd4-cc17-48ec-9830-57c8113d16f6@googlegroups.com> <576b5ea3$0$1595$c3e8da3$5496439d@news.astraweb.com> <576B96C0.2040106@rece.vub.ac.be> <87a8icgw0d.fsf@elektro.pacujo.net> <576BA55E.9030208@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de oVbU9Tb+exvZel+jGK89SwVfpvwmXEUgumMadzZIRi1Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.055 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'received:134': 0.05; 'throw': 0.09; 'exception': 0.13; 'emptiness': 0.16; 'len': 0.16; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; "python's": 0.23; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; 'bugs': 0.27; 'subject:/': 0.30; 'received:be': 0.30; "i'd": 0.31; "can't": 0.32; 'problem': 0.33; 'but': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'no,': 0.38; 'test': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'biggest': 0.67; 'or:': 0.84; 'pardon': 0.84; 'schreef': 0.84; 'write:': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArIIAHYeUleGuA9G/2dsb2JhbABehFsBvRCGEgKCAAEBAQEBAWaEbQEBBCNVEQsaAgUWCwICCQMCAQIBRRMIAogrsU2NPoNbAQEIAiWBAYUmhE2FDII1glkBBJM4hQ2BV4xNiTOFaY9SVINwin4BAQE User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0 In-Reply-To: <87a8icgw0d.fsf@elektro.pacujo.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <576BA55E.9030208@rece.vub.ac.be> X-Mailman-Original-References: <15997174-44d5-431c-8f90-a8d700921820@googlegroups.com> <56ecacd4-cc17-48ec-9830-57c8113d16f6@googlegroups.com> <576b5ea3$0$1595$c3e8da3$5496439d@news.astraweb.com> <576B96C0.2040106@rece.vub.ac.be> <87a8icgw0d.fsf@elektro.pacujo.net> Xref: csiph.com comp.lang.python:110386 Op 23-06-16 om 10:16 schreef Marko Rauhamaa: > I don't particularly like Python's falsey/truthy semantics, but I can > live with it. The biggest problem I have with it is the absence of an > emptiness predicate. I'd like to be able to write: > > if not leftover.empty(): > ... > > or even: > > if not empty(leftover): > ... > > rather than having to say: > > if not leftover: > ... > > or: > > if len(leftover) > 0: # no, I'd never write this > ... Well if I have to test for emptyness, I always write if len(seq) > 0: Because this will throw an exception when len can't apply to seq and so this will catch possible bugs sooner than writing: if not seq. -- Antoon Pardon