
April 28, 2017
7:02 a.m.
On Fri, Apr 28, 2017, at 01:30, Chris Angelico wrote:
Nothing whatsoever says that this is a good idea, but it's perfectly legal, because the for loop is defined in terms of assignment. If this were to be accepted (which, fwiw, I'm not actually advocating, but IF), it would also be defined in terms of assignment. You still shouldn't be assigning to arbitrary objects, especially not randomly rebinding module names, but it's easy to grok the assignment equivalence.
What's not clear is when the left side (an object whose attribute/item is being assigned, and the item index) is evaluated, and why this should be different from when default arguments are evaluated.