[PEP 203] Augmented Assignment

Rainer Deyke root at rainerdeyke.com
Mon Aug 14 16:35:47 EDT 2000


"Frank Niessink" <frankn=nuws at cs.vu.nl> wrote in message
news:8n9gnm$gmg at cs.vu.nl...
> Maybe a stupid question, but why is there no hook for the regular
> assignment in this proposal? The proposal talks about 12 assignment
> operators, of which 11 are 'inplace' and 1 regular. But there is
> no hook for the regular assignment. If a hook would be created for
> regular assignment the object can decide what happens if something is
> assigned to it.

Things cannot be assigned to objects, only to names and sequence/mapping
entries.

> >>> x = Undoable(1)
> >>> print x
> 1
> >>> x = 2
> >>> print x
> 2
> >>> x.undo(); print x
> 1

This is inconsistent with the Python object model.  Assigning to x should
have no effect to the object that x previously refered to, beyond the
decreasing the reference count (with all of the possible side effects this
entails).


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list