Skip to content

Comment on Python Multiple Assignment Is a Puzzleparent

Comments

The first--the latter isn't in order (expr3 is "evaluated" before expr2, which in this case means assignment).

That's precisely the place where I think the description can be improved. With complex assignments, there are two parts: compute the place to store a value, and store the value there. In my mental model, the latter is better called assignment than evaluation.

With Python's evaluation/assignment order, both parts of a complex assignment happen at once--which is the source of the weird behavior in the article (A[0] is assigned to before the subscript of A[A[0] - 1] is evaluated).

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.