Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; '(except': 0.07; 'bug.': 0.09; 'subject:skip:a 10': 0.09; 'tests,': 0.09; 'python': 0.11; 'assume': 0.14; 'comparisons,': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'left,': 0.16; 'precedence': 0.16; 'ternary': 0.16; 'language': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'header:User-Agent:1': 0.23; 'compare': 0.26; 'right.': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'grouping': 0.31; 'operators': 0.31; 'languages': 0.32; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'according': 0.40; 'chain': 0.60; 'mentioned': 0.61; 'skip:n 10': 0.64; 'day': 0.76 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Thu, 06 Mar 2014 10:47:25 -0700 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Ternary operator associativity References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394128062 news.xs4all.nl 2913 [2001:888:2000:d::a6]:54688 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67945 On 03/06/2014 04:34 AM, candide wrote: > According to the official documentation, the ternary operator has left-to-right associativity : > > ------------------- > Operators in the same box group left to right (except for comparisons, including tests, which all have the same precedence and chain from left to right -- see section Comparisons -- and exponentiation, which groups from right to left). > ------------------- > > > Nevertheless, the ternary operator grouping seems to be from right to left, compare : I was reading a blog about PHP the other day and it mentioned PHP was the only language he knew of that had ternary operator precedence going left to right. All other languages use right to left. So I assume that Python also uses right to left and that the documentation is a bug.