On 30/09/2020 19:02, Steven D'Aprano wrote:

But more importantly, unless the right hand side is severely limited, it
is going to be very hard to be unambiguous. The standard augmented 
assignments take *any expression at all* for the right hand side:

    value += 2*x - y

but this could not:

    value .= 2*x - y

I think this is closest on the thread to explaining why this doesn't work, or at least is a semantic nightmare. I've been steeped in descriptors these last several weeks, so I can put it another way: "." is not really an operator, it is attribute access.

Or if one is forced to think of it as an operator, its right operand may only be the name that follows. In translating the "operator", the compiler quotes the right argument as a litereal, rather than evaluating it. Thus:

>>> 'hello'.replace('ell', 'ipp')

means the same as:

>>> ('hello'.replace)('ell', 'ipp')

and the same as:

>>> getattr('hello', 'replace')('ell', 'ipp')

and not:

>>> 'hello'.(replace('ell', 'ipp'))

which doesn't mean anything at all, because "replace('ell', 'ipp')" cannot be the right hand side of ".".

Jeff Allen