Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95912

Re: packing unpacking depends on order.

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.unit0.net!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <random832@fastmail.us>
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; 'test,': 0.05; '*not*': 0.07; '[1,': 0.09; 'assigning': 0.09; 'behavior,': 0.09; 'received:internal': 0.09; 'wed,': 0.15; 'devise': 0.16; 'evaluating': 0.16; 'list"': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'pairs': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.44': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:compute4.internal': 0.16; 'received:messagingengine.com': 0.16; 'result:': 0.16; 'rhs': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'case.': 0.18; 'test.': 0.18; '>>>': 0.20; 'first,': 0.20; 'assign': 0.22; 'sep': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'separate': 0.27; 'question': 0.27; 'executing': 0.27; 'once.': 0.29; 'yields': 0.29; 'list': 0.34; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'agree': 0.37; 'presence': 0.38; 'received:66': 0.38; 'why': 0.39; 'test': 0.39; 'does': 0.39; 'enough': 0.39; 'build': 0.40; 'well.': 0.40; 'to:addr:python.org': 0.40; 'easy': 0.60; 'from:no real name:2**0': 0.60; 'header:Message-Id:1': 0.61; 'side': 0.62; 'evaluate': 0.72; 'first?': 0.84; "it'd": 0.84; 'effects,': 0.91
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; 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=HbosObBDFLUrVal9cEL7FYFNHW8=; b=hzVyAA hIuRwFTgbKhKokGJt7pgnX10coc6dmYjvNzNDqDvOAO93nraaS9CJ6OA10mSr0yD HezXIgw5c8P0ZfdtQHADflYpdi18GmbGBsHn+qoboO0HkFFYC+AQaHjjn4vhBhDn rZlNSVY8S8jD7g1lG9Bxn4JvsvARXkMtinYk0=
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=HbosObBDFLUrVal 9cEL7FYFNHW8=; b=Jkj2cqsRi+JDIkuXO9JCiKQDd0ANNZVkRpGzjdOURw1gQnc TCw7k7e4wt9wDh6eqO9p7YcrEtjERRpt6KMw2MkZbf9+nmepXAYoK4x/4eWZD8dK LyFRJXHhC3QpAq+VhrFBv+Qy91HyCUXbDblVZXdkPkG36Gyd9kLLO7yLcDxY=
X-Sasl-Enc NmE96BsCLMqCu9YGUboIBBL0N3nLAQdHrNNyYjxwr5BP 1441243045
From random832@fastmail.us
To python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type text/plain
X-Mailer MessagingEngine.com Webmail Interface - ajax-4500bf93
Subject Re: packing unpacking depends on order.
Date Wed, 02 Sep 2015 21:17:25 -0400
In-Reply-To <55E73159.4050508@mail.de>
References <55E6C904.3020602@rece.vub.ac.be> <CAGuvt90dWASEjj=_GiZb4jqV4CDF+qqFLH4VS5m_qhUMx6jbJg@mail.gmail.com> <55E73159.4050508@mail.de>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.49.1441243048.8327.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441243048 news.xs4all.nl 23738 [2001:888:2000:d::a6]:39415
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:95912

Show key headers only | View raw


On Wed, Sep 2, 2015, at 13:26, Sven R. Kunze wrote:
> I agree as well. First evaluate the right side, then assign it to the 
> left side at once.

The behavior, if it's *not* "first evaluating the right side", is
indistinguishable from it by this test. Assigning the RHS of each case
to a separate list yields the same result:

>>> a, b = [1, 2, 3, 4, 5], 1
>>> abb = a[b], b
>>> bab = b, a[b]
>>> b, a[b] = abb
>>> a
[1, 2, 1, 4, 5]
>>> a, b = [1, 2, 3, 4, 5], 1
>>> a[b], b = bab
>>> a
[1, 1, 3, 4, 5]

What's happening is this:

>>> abb = a[b], b # 2, 1
>>> bab = b, a[b] # 1, 2
then
>>> b, a[b] = abb # b = 2; a[2] = 1
or
>>> a[b], b = bab # a[1] = 1; b = 2

The question is what does "assign it to the left side at once" even
*mean* in the presence of subscripts? Build up a list of
object-subscript pairs (evaluating all the subscripts, including if any
may have side effects) before executing any __setitem__?

Why is the right side evaluated first? Why not build up this "assignment
destination list" first, before evaluating the right side? They wouldn't
be distinguished by this test, since the RHS has no side effects, but
it'd be easy enough to devise such a test case.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: packing unpacking depends on order. random832@fastmail.us - 2015-09-02 21:17 -0400

csiph-web