Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Gary Herron Newsgroups: comp.lang.python Subject: Re: Operator precedence problem Date: Sun, 5 Jun 2016 00:04:43 -0700 Lines: 32 Message-ID: References: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> <5753CF0B.9040906@digipen.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de PYCm2m4mNV6t2z45meoyjw+24du5tO/SOknOiggK+CfQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: UNSURE 0.446 X-Spam-Level: **** X-Spam-Evidence: '*H*': 0.28; '*S*': 0.18; 'python': 0.10; 'left,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'subject:problem': 0.22; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'linux': 0.26; 'figured': 0.29; 'url:python': 0.33; 'except': 0.34; 'but': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'why': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'charset:windows-1252': 0.62; 'more': 0.63; 'mar': 0.65; 'dr.': 0.69; 'received:204': 0.75; 'institute': 0.77; '(425)': 0.84; '5.3.1': 0.84; '512': 0.84; '895-4418': 0.84; 'digipen': 0.84; 'herron': 0.84; 'ict': 0.84; 'url:reference': 0.91 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> X-Mailman-Approved-At: Mon, 06 Jun 2016 08:05:30 -0400 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: <5753CF0B.9040906@digipen.edu> X-Mailman-Original-References: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> Xref: csiph.com comp.lang.python:109555 On 06/04/2016 11:53 PM, ICT Ezy wrote: >>>> 2 ** 3 ** 2 > Answer is 512 > Why not 64? > Order is right-left or left-right? Evidently right to left, but you already figured that out. Python 3.5.1+ (default, Mar 30 2016, 22:46:26) [GCC 5.3.1 20160330] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 2 ** 3 ** 2 512 >>> 2 ** (3 ** 2) 512 >>> (2 ** 3) ** 2 64 >>> Here's the relevant documentation page: https://docs.python.org/3/reference/expressions.html Look for "... except for exponentiation, which groups from right to left" Gary Herron -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418