Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Michael Torrie Newsgroups: comp.lang.python Subject: Re: Operator precedence problem Date: Sun, 5 Jun 2016 17:47:57 -0600 Lines: 14 Message-ID: References: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> <3ff71354-461a-4635-8d1a-c879243e39a8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de woSCpokfQYd9Wsh0jQtskgJ6YDFEtmhuqGnx1nQ54xdw== 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; 'bug.': 0.07; 'expressions': 0.07; 'precedence': 0.09; '10:05': 0.16; 'division,': 0.16; 'expect,': 0.16; 'expressions,': 0.16; 'extraneous': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'parentheses': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'language': 0.19; 'parse': 0.22; 'subject:problem': 0.22; 'am,': 0.23; '(or': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'tend': 0.27; 'arithmetic': 0.29; 'division': 0.29; 'certainly': 0.30; 'guess': 0.31; 'rules': 0.31; 'implement': 0.32; 'message-id:@gmail.com': 0.34; 'add': 0.34; "isn't": 0.35; 'but': 0.36; 'basic': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'things': 0.38; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'charset:windows-1252': 0.62; 'more': 0.63; 'owing': 0.84 X-Virus-Scanned: amavisd-new at torriefamily.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> <3ff71354-461a-4635-8d1a-c879243e39a8@googlegroups.com> Xref: csiph.com comp.lang.python:109528 On 06/05/2016 10:05 AM, Uri Even-Chen wrote: > My suggestion: Never write expressions, such as 2 ** 3 ** 2 or even 2 * 4 > + 5, without parentheses. Always add parentheses - 2 ** (3 ** 2) (or (2 ** > 3) **2) or (2 * 4) + 5 (or 2 * (4 + 5)). I can understand using parenthesis when operator precedence isn't working the way you want or expect, but I certainly would not recommend using it for basic arithmetic with multiplication, division, addition and subtraction. The rules of precedence for multiplication and division are well known and well-understood. If a language failed to implement them that would be a bug. I think for the simple things extraneous parenthesis makes expressions more difficult for a human to parse because he will tend to second guess himself owing to extra parens.