Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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; 'expressions': 0.07; 'false,': 0.07; 'subject:code': 0.07; 'variable,': 0.07; 'python': 0.09; 'check.': 0.09; 'sure,': 0.09; '(the': 0.15; 'arbitrarily': 0.16; 'boolean': 0.16; 'comparisons,': 0.16; 'conceivably': 0.16; 'expression,': 0.16; 'expression.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'interprets': 0.16; 'parentheses': 0.16; 'wrote:': 0.17; 'integer': 0.17; 'putting': 0.20; 'received:209.85.214.174': 0.21; 'implicit': 0.22; 'latter': 0.22; 'stick': 0.22; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; "d'aprano": 0.29; 'steven': 0.29; 'knows': 0.30; "skip:' 10": 0.30; 'evaluation': 0.30; 'expect': 0.31; 'like:': 0.33; 'true.': 0.33; 'to:addr:python- list': 0.33; 'everyone': 0.33; 'another': 0.33; 'that,': 0.34; "can't": 0.34; 'received:google.com': 0.34; 'false': 0.35; 'replaced': 0.35; 'same.': 0.35; 'skip:l 30': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'usual': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:( 30': 0.38; 'from:': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'different': 0.63; 'more': 0.63; 'jul': 0.65; 'asterisk': 0.84; 'say:': 0.84 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 :content-type; bh=KhSHSkrlt/F1pgGumIquT3INOCFmWofPcmGE8i/7kDM=; b=RTSZ5IN+SaBbR4e2ltrMzYa52uvxzaykILTh9aW/9wrBOEKLNrrREraFXWhIZee87S OdMfz1kyhRTbpez4r5buvKvJFkgdIW2mRLrU34QAXxRisbONJwBqmVBg5PDEAUfYh3Dh 3hraILpdLkFsBksEv9faSYnqnGdPdtHaIbl54SID6snXXTiAwNalP3m3S81ZwG7/BO0V hZv/HDvCicVXXxnJ2Q+zxn4v05iz1TuTSmWc8iNVT7UFoip54MJ/Dy6i1Q+6svnhoySQ OU62OaWL32QMBwlJFT1GHBvkib1r+5TynCzJt7B9oDZE/90Cv7h6Q0cj8u+V6KeCylp1 uK4Q== MIME-Version: 1.0 In-Reply-To: <4fefb0ad$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <6c39594f-79cb-4d4f-967e-bbc3f68cdbdf@f8g2000pbf.googlegroups.com> <4fed59b7$0$29978$c3e8da3$5496439d@news.astraweb.com> <2662370.TGmo96CKe1@PointedEars.de> <87wr2oecf6.fsf@dpt-info.u-strasbg.fr> <4FEF7117.7000109@jollybox.de> <4fefb0ad$0$29988$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 1 Jul 2012 12:20:52 +1000 Subject: Re: code review From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341109256 news.xs4all.nl 6843 [2001:888:2000:d::a6]:34979 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:24715 On Sun, Jul 1, 2012 at 12:06 PM, Steven D'Aprano wrote: > You can't just arbitrarily stick parentheses around parts of expressions > and expect the result to remain unchanged. Order of evaluation matters: > > 2**3**4 != (2**3)**4 But that's because ** binds right to left. It _is_ valid to say: 2**3**4 = 2**(3**4) That's the usual way of depicting order of evaluation: putting in the implicit parentheses. 1+2*3 = 1+(2*3) Everyone who knows algebra knows that the parens are optional, but nobody would expect them to change the evaluation of the expression. It's like adding whitespace: 1+2*3 = 1 + 2 * 3 = 1 + 2*3 where the latter is another way of showing order of evaluation (the asterisk "binds more tightly" than the plus). With comparisons, it's not the same. (a