One last shot at the Augmented Assignment PEP
wfocke at phoenixdsl.com
Thu Sep 14 23:37:37 CEST 2000
> I imagine that many hours of time will be wasted explaining to
> Pythion newbies on comp.lang.python why these unpleasant side-effects
We already spend those hours explaining why
a = 
b = a
b = 1
> They look like assignment in other languages, but not at all
> like the reference-based name-binding assignment of python.
> so-called "assignment" in Python is not really what programmers of C,
> Fortran, etc, think of as "assignment", but, actually, it's *binding*
> [or re-binding]
> In 1.5.2 and preceding implementations we have got used to the idea that
> a variable is, in fact, a pointer (or reference) to a value, and that if
> we "modify the value of a variable" we are actually computing a new value
> and then replacing the current variable's content with a reference to that
> new value.
I've always been tempted to tell people to think of "=" as binding, not
assignment, but even in versions <= 2.0, it didn't always mean that:
a = 
a = 1
No symbol rebinding here, although we have copied a reference.
b = array.array()
b = 1
And here we haven't even done that.
> Yup. I suppose the real dastardly part of the PEP is this:
> "To make this possible, a number of new `hooks' are added to Python
> In other words, you have to know whether each type possesses the new
> hooks in order to be able to predict the effects of the operations.
But we already have to know how objects interpret operations in order to
predict the results. E.g., does evaluating the expression
a + 0
mail the attack plans to the enemy before or after wiping the hard drive?
In short, the amount of time we spend explaining things to people who didn't
read the instructions, and the consistency of interpretation of "=", and what
we have to know haven't changed much. But now some things can be expressed
more clearly, and in some cases, implemented more effieciently.
Just because romance and rapture have so often served as a pretext for
curdled banality doesn't make the sentiments themselves obsolete.
-- Michelle Goldberg
More information about the Python-list