Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Random832 Newsgroups: comp.lang.python Subject: Re: Operator precedence problem Date: Sun, 05 Jun 2016 13:19:33 -0400 Lines: 12 Message-ID: References: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> <1465147173.2666461.628499265.4DB6AD8F@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de RpirFgpqyHNU6jWx9iH3zQeNzOR6kudNbdN2pKTi0OJQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'operator': 0.03; 'received:internal': 0.09; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'subject:problem': 0.22; 'elements': 0.23; 'header:In-Reply-To:1': 0.24; 'evaluation': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'two': 0.37; 'received:66': 0.38; 'means': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'header:Message-Id:1': 0.61; 'side': 0.62; 'more': 0.63; 'different': 0.63; 'here': 0.66; '512': 0.84; 'ict': 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=nDnjzxmpTbD88lappIXb/59Yga0=; b=4F7bnL trDB2i5OgxHoJwOS6tgpfJRxuEjiLcHJ5J4a/4mthjh4gLgLBY4vnhXSACxu/XVV hjOCvdRmmb7iJ0w0ug6GqRbLvuuKkycjq49JLN+YKMeDS5t/aBNFqUdCVR8XZ3uQ pPObAftcJnMgFM7Zd+k3xhea+SwEMmIcD0yP0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=nDnjzxmpTbD88la ppIXb/59Yga0=; b=fl5mtsf+mQSKmt/ifiWdrqxRPKo+2u+0JvHjeLT+n9q0xFx HKVM2R0dWT2cJxc83XHmFLY8z65hA6hvvfwdU9CWg3ybXJaCR0BM0RH/1kE1z/Tm 3TIdc6fTZoUIk3OmEMkDmERX0CTotEbexSWv5UhR1VZgxBv1WrTI1rFL0YAw= X-Sasl-Enc: QByxTzZysb2S13NvNqkSRL3pvs1KotXxp712+hui1w2I 1465147173 X-Mailer: MessagingEngine.com Webmail Interface - ajax-2bd3df2b In-Reply-To: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> 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: <1465147173.2666461.628499265.4DB6AD8F@webmail.messagingengine.com> X-Mailman-Original-References: <816c651a-d0ae-4e23-a5b2-72a8f7398468@googlegroups.com> Xref: csiph.com comp.lang.python:109519 On Sun, Jun 5, 2016, at 02:53, ICT Ezy wrote: > >>> 2 ** 3 ** 2 > Answer is 512 > Why not 64? > Order is right-left or left-right? You're mixing up order of evaluation with operator associativity. The ** operator is right-to-left associative, this means x ** y ** z == x ** (y ** z). Evaluation is left to right, where it matters [i.e. if one or more of the elements here were an expression with side effects]: first x is evaluated, then tmp=y**z, then x**tmp. These are two entirely different concepts.