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


Groups > comp.lang.python > #103003

Re: Multiple Assignment a = b = c

From "Sven R. Kunze" <srkunze@mail.de>
Newsgroups comp.lang.python
Subject Re: Multiple Assignment a = b = c
Date 2016-02-16 14:10 +0100
Message-ID <mailman.164.1455628234.22075.python-list@python.org> (permalink)
References <CACs7g=C6AZVOtFg7ufNo09jt3oG006GH=onNbY3SH6Oc_TqYOw@mail.gmail.com> <56C31E9E.1060609@mail.de>

Show all headers | View raw


On 16.02.2016 14:05, Sven R. Kunze wrote:
> Hi Srinivas,
>
> I think the tuple assignment you showed basically nails it.
>
> First, the rhs is evaluated.
> Second, the lhs is evaluated from left to right.
>
> Completely wrong?
>
> Best,
> Sven

As you mentioned swapping. The following two statements do the same (as 
you suggested at the beginning).

a,b=b,a=4,5
(a,b),(b,a)=(4,5),(4,5)

Best,
Sven

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


Thread

Re: Multiple Assignment a = b = c "Sven R. Kunze" <srkunze@mail.de> - 2016-02-16 14:10 +0100

csiph-web