Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'operator': 0.03; 'english.': 0.04; 'syntax': 0.04; '"if': 0.09; 'english,': 0.09; 'if,': 0.09; 'logic': 0.09; 'messing': 0.09; 'separately': 0.09; 'subject:test': 0.09; 'cc:addr:python-list': 0.11; 'algebra,': 0.16; 'confuse': 0.16; 'evaluation;': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ha!': 0.16; 'mathematics.': 0.16; 'operator.': 0.16; 'personally,': 0.16; 'syntax,': 0.16; 'ternary': 0.16; 'sat,': 0.16; 'wrote:': 0.18; "python's": 0.19; 'programming': 0.22; 'cc:addr:python.org': 0.22; 'either.': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'external': 0.29; "doesn't": 0.30; 'compared': 0.30; 'evaluation': 0.30; 'have,': 0.30; 'message-id:@mail.gmail.com': 0.30; '25,': 0.31; "d'aprano": 0.31; 'follows': 0.31; 'steven': 0.31; 'url:python': 0.33; 'agree': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'programming,': 0.36; 'url:org': 0.36; 'pm,': 0.38; 'even': 0.60; 'expression': 0.60; 'url:3': 0.61; 'such': 0.63; 'between': 0.67; 'to,': 0.72; 'it"': 0.84; 'url:reference': 0.84; 'subject::': 0.85; '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=ZkHkjgrNgemGtTBp43i/d725WmJqOe5zw3L+8CrMj1A=; b=BLkCcASCcCS3hf9peabuJ+k5jsyd5PL+dcYDs/JDvx9zpha4BQr7HtfPKuVbJhh+je FHkVPcViLQijCpgcXwKlHslM6u+E1cBKNtE8uxYtZM/PQALQndSd4LMjXGayVrfPBEnw o7wxXbutT6Lb6l/eTzXRqHlCZj8oGN22uLT2MKuQmXb93LX+M4X89dkfS3KO0HX+3E8K 6YiXAb6GVJ4qOWt6WoJP311vsy3DqX9rdXcNLLdnBx5g+d6C0RkwrVeDbrQG6x2/LnBi tDJKXgcYRXEf46bxbZu2g+aBQy5W1pUaNayvduNlnQUUSBNNxRfk+n7MZlR+OlhkSjzW 259g== MIME-Version: 1.0 X-Received: by 10.50.43.130 with SMTP id w2mr8174025igl.34.1414214759693; Fri, 24 Oct 2014 22:25:59 -0700 (PDT) In-Reply-To: <544b2f15$0$12978$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> Date: Sat, 25 Oct 2014 16:25:59 +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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414214761 news.xs4all.nl 2872 [2001:888:2000:d::a6]:55405 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79655 On Sat, Oct 25, 2014 at 4:03 PM, Steven D'Aprano wrote: > Ha! And yet people have, and continue to, complain *bitterly* about the > non-standard ordering of Python's ternary if, compared to C, standard > if...else syntax, and English. > > "If the syntax is like C, then people will use it, or else they will > complain that the syntax is incomprehensible." > > Personally, I don't accept or agree with such complaints. Python's ternary > if follows the same syntax as this English variant: > > "People will use it if the syntax is like C, or else they will complain that > the syntax is incomprehensible." Partly, I think this is a difference between programming and pure mathematics. In algebra, there's operator precedence, but no order of evaluation; in programming, there's both: https://docs.python.org/3/reference/expressions.html#evaluation-order In English, there's not really a concept of order of evaluation either. "People will use it" doesn't need to be evaluated separately from "if the syntax is like C". But in Python, the if/else operator mucks up the general principle that an expression will be evaluated left-to-right, because it's evaluated middle-to-outer for that one operator. Messing with internal expectations, even if it's following some external logic like English grammar, will confuse people. ChrisA