On Wed, Oct 29, 2008 at 14:33, Eric Firing <efiring@hawaii.edu> wrote:
> David Warde-Farley wrote:
>> Hi Fernando,
>>>> In Robert's comment, I think the reST processor somehow got rid of a
>> backslash. In my browser I see
>>>> (I'm looking at you, Matlab's "")
>>>> although this is an aside that will be lost on anyone who hasn't used
>> the Matlab backslash operator anyway.
>>>> In fact, one other thing just came to mind that isn't obvious and (so
>> far as I can remember) hasn't been brought up: even though Robert and
>> others (myself included) really only care about an operator to
>> facilitate matrix multiplication, I think most of us would support the
>> ~*= (mentioned in the PEP) as a natural companion to ~*.
>> This makes no sense to me at all. Why use in-place notation for an
> operation that is not in-place? The point of having a matrix
> multiplication operator is to facilitate code that corresponds more
> closely to mathematical notation. The in-place operations live in the
> computer science world, not the mathematical world. The proposal for
> ~*= violates language consistency while doing nothing to improve
> mathematical readability.
Eh, that's not entirely true.
x = 1
x += 2
That's not in-place. They are called "augmented assignments", not
"in-place operations" for this reason. The defining characteristic is
that "x <op>= y" should be equivalent to "x = x <op> y" except
possibly for *optional* in-place semantics.
But this isn't a choice for us to make. If we add operators to the
Python language, their associated augmented assignments will also be
added (no matter what we think about it). If a class doesn't define
the appropriate __magic__ method, then Python will execute "x = x <op>
y" and give us the semantics that David was suggesting. This is a
non-controversy.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco