Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.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; 'example:': 0.03; 'read.': 0.03; 'indexing': 0.07; 'dan': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:test': 0.09; 'python': 0.11; 'language.': 0.14; '"standard': 0.16; '24,': 0.16; '>>>i': 0.16; '>>on': 0.16; '>on': 0.16; '[f,': 0.16; 'programmers.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'index': 0.16; 'wrote:': 0.18; 'obviously': 0.18; '>>>': 0.22; 'example': 0.22; 'header:User-Agent:1': 0.23; 'received:comcast.net': 0.24; 'mention': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "skip:' 10": 0.31; '-0700,': 0.31; '>>>>': 0.31; 'becoming': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'anyone': 0.31; 'quite': 0.32; 'fri,': 0.33; 'style': 0.33; 'no,': 0.35; 'but': 0.35; 'doubt': 0.36; 'false': 0.36; 'should': 0.36; 'clear': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'read': 0.60; 'most': 0.60; 'course': 0.61; 'more': 0.64; 'opinions': 0.70; "today's": 0.70; 'obvious': 0.74; 'subject::': 0.85; 'apparent': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: (test) ? a:b Date: Sat, 25 Oct 2014 07:58:14 -0400 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <544b2f15$0$12978$c3e8da3$5496439d@news.astraweb.com> 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414238308 news.xs4all.nl 2852 [2001:888:2000:d::a6]:54142 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79664 On 10/25/14 1:03 AM, Steven D'Aprano wrote: > alister wrote: > >> >On Fri, 24 Oct 2014 10:20:30 -0700, Dan Stromberg wrote: >> > >>> >>On Fri, Oct 24, 2014 at 1:38 AM, Steven D'Aprano >>> >> wrote: >>>> >>>I don't get why that's considered hard to read. >>> >> >>>> >>>So why is it hard to read when the index is a flag? >>>> >>> >>>> >>>value = [f, g][cond]() >>> >> > [Dan] >>> >>It's clear to you, it's clear to me, but is it clear to everyone? I >>> >>very much doubt it. > Of course it won't be clear to*everyone* but it should be clear enough to > people who are familiar with standard Python idioms. A concrete example > should be more obvious than the fake example: > > title = ('Mr', 'Ms')[person.sex == 'F'] > > which should be clear to anyone who understands indexing in Python and that > True == 1 and False == 0. You mention "standard Python idioms." I think this style of conditional-via-indexing is becoming quite uncommon, and is no longer one of the standard Python idioms. This is now in the category of "outdated hack." Yes, its meaning is well-defined by the language. But no, its meaning is not immediately apparent to most of today's Python programmers. Of course, opinions obviously differ. -- Ned Batchelder, http://nedbatchelder.com