Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93621
| References | <436cb6ac-59a4-44f1-be60-cdec1e509296@googlegroups.com> |
|---|---|
| Date | 2015-07-10 12:02 +1000 |
| Subject | Re: Evaluation order |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.379.1436493764.3674.python-list@python.org> (permalink) |
On Fri, Jul 10, 2015 at 10:10 AM, candide <c.candide@laposte.net> 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? I'm not sure what contradiction you're referring to, here. The evaluation that you're pointing out says, as Terry showed via the disassembly, that Python's first action is to look up the name 't' and grab a reference to whatever object it points to. The execution of t.sort() has to happen before the multiplication, because of the parentheses. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Evaluation order candide <c.candide@laposte.net> - 2015-07-09 17:10 -0700
Re: Evaluation order Terry Reedy <tjreedy@udel.edu> - 2015-07-09 21:45 -0400
Re: Evaluation order Chris Angelico <rosuav@gmail.com> - 2015-07-10 12:02 +1000
Re: Evaluation order candide <c.candide@laposte.net> - 2015-07-10 05:04 -0700
Re: Evaluation order Ned Batchelder <ned@nedbatchelder.com> - 2015-07-10 05:19 -0700
Re: Evaluation order Terry Reedy <tjreedy@udel.edu> - 2015-07-10 08:27 -0400
Re: Evaluation order Chris Angelico <rosuav@gmail.com> - 2015-07-11 00:27 +1000
Re: Evaluation order Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-10 15:49 +0100
csiph-web