Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95884
| References | <55E6C904.3020602@rece.vub.ac.be> <ms7cfh$k4h$1@ger.gmane.org> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2015-09-02 12:06 -0600 |
| Subject | Re: packing unpacking depends on order. |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.26.1441217727.8327.python-list@python.org> (permalink) |
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 | Next — Next in thread | Find similar | Unroll 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