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


Groups > comp.lang.python > #95884

Re: packing unpacking depends on order.

Path csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.027
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; '[1,': 0.09; 'python': 0.10; 'wed,': 0.15; '11:42': 0.16; 'former,': 0.16; 'reedy': 0.16; 'reproduce': 0.16; 'temp': 0.16; 'wrote:': 0.16; '2015': 0.20; 'do.': 0.22; 'sep': 0.22; 'am,': 0.23; 'code.': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'cases.': 0.29; "i'm": 0.30; 'gets': 0.35; 'received:google.com': 0.35; 'but': 0.36; 'should': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'easily': 0.39; 'to:addr:python.org': 0.40; 'behavior': 0.61; '>>>>>': 0.66; 'results': 0.66; 'pardon': 0.84; 'to:name:python': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=5x5bPrMTIYbab7Q1vrE+pGt5amA37NZqwOhM3g5IK9g=; b=G4SzYNYa7iXx4fLNLrYjKA8RxhctQ5VvcuUEtSDwwEY2X+VoSGSq9bGpNmvbMoeIrr d4l6w+lqi7lXanXOjB/JFmV/msUlJcWGDw22UGAX8oisYRPQgi8ITHoBN4Leq7wNmXNQ XAPlutoW+bxK4a10zfkm0pPPVcY4zsZ4MQc+rUkdYeMTd97wv2mHJv2ldni4yonIcw0a iuGbGDQOMhFwBGvTf4XrfLl1N8tQcQb6HcLOe+P6sZJmDVsZadaX0chiehehabPeTLUO tFmslkLxLyX7n0jQEe5Uv5AphOvwDE9h9bUwXgBTeygJ9WWXMuY20yWoEEozcQYGbPRb QkbQ==
X-Received by 10.129.51.88 with SMTP id z85mr24078463ywz.148.1441217235366; Wed, 02 Sep 2015 11:07:15 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <ms7cfh$k4h$1@ger.gmane.org>
References <55E6C904.3020602@rece.vub.ac.be> <ms7cfh$k4h$1@ger.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 2 Sep 2015 12:06:32 -0600
Subject Re: packing unpacking depends on order.
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.26.1441217727.8327.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441217727 news.xs4all.nl 23727 [2001:888:2000:d::a6]:53626
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:95884

Show key headers only | View raw


On Wed, Sep 2, 2015 at 11:42 AM, Terry Reedy <tjreedy@udel.edu> wrote:
> On 9/2/2015 6:01 AM, Antoon Pardon wrote:
>>
>>
>>>>> a = [1, 2, 3, 4, 5]
>>>>> b = 1
>>>>> b, a[b] = a[b], b
>>>>> a
>>
>> [1, 2, 1, 4, 5]
>>>>>
>>>>> a = [1, 2, 3, 4, 5]
>>>>> b = 1
>>>>> a[b], b = b, a[b]
>>>>> a
>>
>> [1, 1, 3, 4, 5]
>>
>> I think I understand how it gets these results
>> but I'm not really happy with them. I think python
>> should give the second result in both cases.
>
>
> I do not want the choice taken away from me.

I do. I think the former behavior is surprising, and that relying on
it would result in confusing, hard-to-read code. If you really want
the former, you can easily reproduce it with:

temp = a[b]
b, a[temp] = temp, b

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


Thread

Re: packing unpacking depends on order. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-02 12:06 -0600
  Re: packing unpacking depends on order. Steven D'Aprano <steve@pearwood.info> - 2015-09-03 11:45 +1000
    Re: packing unpacking depends on order. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-02 21:32 -0600

csiph-web