On Thu, Mar 1, 2018 at 6:35 AM, Brendan Barnwell <email@example.com> wrote:
> On 2018-02-28 07:18, Chris Angelico wrote:
>> Except that assignment is evaluated RHS before LHS as part of a single
>> statement. When Python goes to look up the name "a" to store it (as
>> the final step of the assignment), the SLNB is still active (it's
>> still the same statement - note that this is NOT expression-local), so
>> it uses the temporary.
> Wait, so you're saying that if I do
> a = (2 as a)
> The "a = " assignment assigns to the SLNB, and so is then discarded
> after the statement finishes?
> That seems very bad to me. If there are SLNBs with this special
> "as" syntax, I think the ONLY way to assign to an SLNB should be with the
> "as" syntax. You shouldn't be able to assign to an SLNB with regular
> assignment syntax, even if you created an SNLB with the same name as the LHS
> within the RHS.
That seems a reasonable requirement on the face of it, but what about
a = (x as a)
a[b] = (x as a)
b[a] = (x as a)
a[b].c = (x as a)
b[a].c = (x as a)
Which of these should use the SLNB, which should be errors, which
should use the previously-visible binding of 'a'?