assignment hook

Fredrik Lundh fredrik at pythonware.com
Sun Sep 24 13:35:31 CEST 2006


Georg Brandl wrote:

> This is not possible. Assignments in the form
> 
> name = value
> 
> (also called "binding a name") are not overloadable.

footnote: unless you execute the code in a controlled environment:

     class mydict(dict):
         def __setitem__(self, key, value):
             print "SET", key, value
             self.__dict__[key] = value

     ns = mydict()

     exec "a = 10" in ns

</F>




More information about the Python-list mailing list