Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'read.': 0.03; 'subject:test': 0.09; 'cc:addr:python-list': 0.11; '24,': 0.16; '[f,': 0.16; 'cc:name:python list': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'index': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'fri,': 0.33; 'trouble': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'doubt': 0.36; 'two': 0.37; 'clear': 0.37; 'read': 0.60; 'gone': 0.61; "you've": 0.63; 'here': 0.66; 'subject::': 0.85 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:to :cc:content-type; bh=hqU0M3RMcMWynwZJ4Tlq0Uo+pQMFurZ3Ga+GuXI9Ess=; b=PPnpIvz+MpLMDafsr8g/yB5ynRWo9B93Z5Cu8oBhpqFWkbD36jWqdMY4BlY1iAcXEz 2Fe4GDQEBvLa675isjMbFhgYw+8bm89pcu9ohHAxgbl3pLWaXPGKHY01hK4jDDFmZmVg /p2y6o8DbesWa9N9RxJCWlREbzWUQmet3GeJKYitv5J8py5ClQgK2F17JjvZ2tsFcnw4 qClqqmw8wCFJyzJ4qNY8/N/jWP05N2LWZjutFCyihlOLh2ImztZOO/oxylTPthlzNMyw 0VeFnUma6ztnUa2qUxHHeu8MNlpUqqW1xO730IAg/s67pqeY/mmv3Bx4321YOzsP+JaJ x3ag== MIME-Version: 1.0 X-Received: by 10.152.5.129 with SMTP id s1mr5972244las.59.1414171230587; Fri, 24 Oct 2014 10:20:30 -0700 (PDT) In-Reply-To: <544a1016$0$13000$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> Date: Fri, 24 Oct 2014 10:20:30 -0700 Subject: Re: (test) ? a:b From: Dan Stromberg To: "Steven D'Aprano" Content-Type: text/plain; charset=UTF-8 Cc: Python List 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414171237 news.xs4all.nl 2897 [2001:888:2000:d::a6]:47180 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79590 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]() It's clear to you, it's clear to me, but is it clear to everyone? I very much doubt it. Also, you've gone to the trouble of def'ing two functions here - you may as well do a function for the if/else.