[PEP 203] Augmented Assignment

Frank Niessink frankn=nuws at cs.vu.nl
Tue Aug 15 12:48:15 EDT 2000


Thomas Wouters <thomas at xs4all.net> wrote:
> On Mon, Aug 14, 2000 at 07:19:18PM +0000, Frank Niessink wrote:

>> 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.

> If you look closely, you see that the only thing the '_ab_' hooks do is the
> 'binary' part of the 'binary-assignment' combination that is augmented
> assignment. Assignment in Python is a simple name-binding operation, not the
> variable-filling operation it is in most other languages. Named variables
> are like object indices. Which object would you expect to implement the
> actual object storage in this expression:

> list[10] = x

> Or

> dict["10"] = x

Here the __assign__ of the object currently pointed to by list[10]
or dict["10"] would simply be called (if present)...

> In any case, this isn't likely to change, PEP or not. The 'name-binding'
> type of assignment is at the heart of Python.

Well, my silly proposal doesn't change the name binding in normal 
situations, it only makes it possible to override the name binding.

(Not that I'm expecting this is going to happen).

Cheers, Frank

-- 
The main town was called OhWell. There weren't any other towns to speak of. 
Settlement on NowWhat had not been a success and the sort of people who 
actually wanted to live on NowWhat were not the sort of people you would want 
to spend time with.
	-- Douglas Adams, 'Mostly Harmless'



More information about the Python-list mailing list