Augument assignment versus regular assignment

Terry Reedy tjreedy at udel.edu
Tue Jul 18 14:51:14 EDT 2006


"Antoon Pardon" <apardon at forel.vub.ac.be> wrote in message 
news:slrnebpb99.tg1.apardon at rcpc42.vub.ac.be...
> On 2006-07-17, Terry Reedy <tjreedy at udel.edu> wrote:
>>  Or, whether docs (and reasonable interpretation thereof) and
>> implementation match, which I claim they do it this case.

The claim, in reference to the CPython implementation, that you refer to 
below.

> Well this dispute seems to boil down what is and what is not
> involved in evaluating a target,

Yes, and that is interpreter/implementation dependent.

> and I have come to doubt that
> target evaluation is even a meaningfull concept in python,

Abstractly, it is whatever the interpreter does before it actually attaches 
an object to the name or slot.  Again, the details are interpreter 
dependent.

> so maybe in order that I can understand how you come to that claim,

I looked at the CPython bytecode and saw that for augmented assigment, it 
saved on the stack the internal information it needed for get and set 
instead of recalculating it after the operation.  This is what I expected 
and what I think the docs imply.

> can you explain what a target evaluates to?

The internal information the interpreter needs to do the assignment 
(binding).

> So in a statement like
>  col['t'] = exp
> What is the evaluation of col['t']?

Try some personal introspection.  When you act as a Python interpreter, 
what do you do?

> So I think one should take extra care in the language reference to
> write in a way that is as clear as possible. IMO there is room for
> improvement in the augmented assignment part.

I already agreed.  I might someday suggest a change.

Terry Jan Reedy






More information about the Python-list mailing list