Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!ecngs!feeder2.ecngs.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.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; 'expressions': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'python': 0.10; 'jan': 0.11; '(int)': 0.16; '42,': 0.16; 'evaluates': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'sorts': 0.16; 'wrote:': 0.16; 'byte': 0.18; '>>>': 0.20; 'doc': 0.22; 'header :In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'right.': 0.27; 'code': 0.30; 'url:python': 0.33; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'keyword': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'no,': 0.38; '(1)': 0.38; 'to:addr:python.org': 0.40; 'some': 0.40; 'url:3': 0.60; 'received:fios.verizon.net': 0.91; 'url:reference': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Evaluation order Date: Thu, 9 Jul 2015 21:45:56 -0400 References: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-98-114-97-173.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 In-Reply-To: <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436492779 news.xs4all.nl 2829 [2001:888:2000:d::a6]:49264 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93620 On 7/9/2015 8:10 PM, candide wrote: > The official doc explains that : > Python evaluates expressions from left to right. > cf. https://docs.python.org/3.3/reference/expressions.html#evaluation-order > But consider the following snippet : > >>>> t=[2020, 42, 2015] >>>> t*(1+int(bool(t.sort()))) > [42, 2015, 2020] > Is there not some contradiction with left-right evalutation? No, as shown by the disassembled byte code >>> dis.dis("t*(1+int(bool(t.sort())))") 1 0 LOAD_NAME 0 (t) 3 LOAD_CONST 0 (1) 6 LOAD_NAME 1 (int) 9 LOAD_NAME 2 (bool) 12 LOAD_NAME 0 (t) 15 LOAD_ATTR 3 (sort) 18 CALL_FUNCTION 0 (0 positional, 0 keyword pair) 21 CALL_FUNCTION 1 (1 positional, 0 keyword pair) 24 CALL_FUNCTION 1 (1 positional, 0 keyword pair) 27 BINARY_ADD 28 BINARY_MULTIPLY 29 RETURN_VALUE t.sort() sorts in place and returns None -- Terry Jan Reedy