Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.125 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.76; '*S*': 0.01; 'counting': 0.09; 'lines.': 0.09; 'subject:test': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'personally,': 0.16; 'tally': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'value.': 0.19; 'portion': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'time:': 0.31; 'actual': 0.34; "i'd": 0.34; 'could': 0.34; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'list.': 0.37; 'pm,': 0.38; 'rather': 0.38; 'anything': 0.39; 'even': 0.60; "you're": 0.61; 'more': 0.64; 'different': 0.65; '26,': 0.68; 'obvious': 0.74; 'counted,': 0.84; 'difference.': 0.84; 'filtered': 0.84; 'significance': 0.84; 'subject::': 0.85; 'thing,': 0.91; 'to:none': 0.92 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:cc :content-type; bh=4inAwN0wI3eFMFbKQ3ZNhKMCnu9Hk+2unVx9T32XRr4=; b=YcF7JgCP1r5NflwGQT21zkjJCbnEXXH/MgOhweCSZD1nP+Xg9sxrFu8A5e3Vg/FyQB d1xzz1zZYOtVxH62dXAV2Uv9LPPlzKVZtt02LezzNHklK0nq1FivlTRk7wMFYfqSwxKf aRrTfO288wQ/ULLr8hsbs87I8vHTNPPntl53mi9wZg3lV8Ub0qOqe65QFxinjvVOayjT zVOw7h3KYdJ9pBMc195E5GSZ9tU6wiXF2lIB8jCEss8LrTaFYusHR/QN+F6ZvLBbNt6+ jg54Rsqql86vZltvFLbFUBMrN+AyXAK3kxaNmKZsDf/+kf2ZV8Dtd84MJBlgHdwpKYwZ GxeA== MIME-Version: 1.0 X-Received: by 10.50.79.167 with SMTP id k7mr13589170igx.14.1414298082278; Sat, 25 Oct 2014 21:34:42 -0700 (PDT) In-Reply-To: <544c754b$0$12991$c3e8da3$5496439d@news.astraweb.com> References: <54476af8$0$21651$426a74cc@news.free.fr> <7839376e-fc27-4299-ae63-4ddf17ef9a8a@googlegroups.com> <7d2ea3c1-504e-4f5c-8338-501b1483df38@googlegroups.com> <878uk6x5nd.fsf@elektro.pacujo.net> <544a1016$0$13000$c3e8da3$5496439d@news.astraweb.com> <544b2f15$0$12978$c3e8da3$5496439d@news.astraweb.com> <544c3bde$0$12988$c3e8da3$5496439d@news.astraweb.com> <544c754b$0$12991$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 26 Oct 2014 15:34:42 +1100 Subject: Re: (test) ? a:b From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414298085 news.xs4all.nl 2950 [2001:888:2000:d::a6]:58121 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79703 On Sun, Oct 26, 2014 at 3:15 PM, Steven D'Aprano wrote: > Since the list items exist only to be counted, the actual item used makes no > difference. You could use any value at all, or even a different value each > time: > > len([random.random() for line in lines if not line.strip()]) > > What is your reason for the choice of True as the tally marker? It doesn't > clarify your intent, or make it more obvious that you're counting the > number of non-empty lines. Personally, I'd use the original value. When you're counting something, it's common to count that thing, rather than some stand-in. len([line for line in lines if not line.strip()]) But that's no better than anything else. The only significance is that it feels more like counting a filtered portion of the list. ChrisA