Reputation: 21
I cannot understand the code as follows:
>>> foo, bar = foo[bar] = [1,2,3], 2
>>> foo
>>> [1, 2, ([...], 2)]
>>> bar
>>> 2
In my opinion,
>>> foo, bar = foo[bar] = [1,2,3], 2
is a multiply assignments, which can be written as:
>>> foo[bar] = [1,2,3], 2
>>> foo, bar = foo[bar]
obviously, the 1st assignment will cause error.
However, the foo, bar = foo[bar] = [1,2,3], 2
is amazingly legal, and show me a strange result.
who can explain why?
I expecting that someone can explain to me.
Upvotes: 0
Views: 40