On Wed, 2007-08-08 at 08:52 -0400, Steve Holden wrote: > While it's correct that rebinding y will usually cause it to reference a > different object, this need not be true of assignment. The augmented > assignment operations do no necessarily rebind their left-hand operand - > that depends on the implementation of the relevant method in whatever > type is the subject of the augmented assignment. > > An *assignment* to y therefore *usually* rebinds the name y to point to > a different value.
You are certainly correct within the bounds of the terminology you're using, but I think some clarifications are necessary. The language reference draws a clear distinction between assignments and augmented assignments. In an augmented assignment, the difference between a mutable target and a non-mutable target is indeed of utmost relevance. However, drawing this distinction into a discussion about what *assignments* will and won't do is confusing matters. In a "plain" assignment of the form "name = expression", the mutability of the object that the name is pointing to, if any, does not matter. I believe that that was the point greg was trying to make when he objected to this statement of yours: """ When the function starts out with None as y's value any assignment to y causes it to reference a different value (since None is immutable). So the next time the function is called y is pointing at the None that it was pointing at the last time the function was called (since None cannot be mutated). """ The problem is your ambiguous use of the word "assignment." In the sense of the Language Reference, "any assignment to y" is a simple assignment that always modifies a namespace and never modifies an object. In that sense, the mutability of None really isn't the issue. If you use the broader sense in which "assignment" includes augmented assignments, the mutability of None does become relevant. I agree that greg's delivery was unduly disrespectful, but I think he was making a valid point. Hope this helps clear up the confusion. Best regards, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list