Re: assignment hook

2006-09-24 Thread Fredrik Lundh
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): pri

Re: assignment hook

2006-09-24 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > Kind people, > Is there any way one can, within Python, intercept the act of > assignment. For instance, suppose that I was obsessed with > FORTRAN II, and decided that I wanted to print a warning, > or raise an exception any time someone assigned an int to a > variable

Re: assignment hook

2006-09-23 Thread John Machin
Roy Smith wrote: > [EMAIL PROTECTED] wrote: > > Kind people, > > Is there any way one can, within Python, intercept the act of > > assignment. > > Sure. You just need to define a __setattr__() method for your class. See > http://docs.python.org/ref/attribute-access.html for details. Is it possi

Re: assignment hook

2006-09-23 Thread Roy Smith
[EMAIL PROTECTED] wrote: > Kind people, > Is there any way one can, within Python, intercept the act of > assignment. Sure. You just need to define a __setattr__() method for your class. See http://docs.python.org/ref/attribute-access.html for details. > For instance, suppose that I was obses

assignment hook

2006-09-23 Thread paul . lafollette
Kind people, Is there any way one can, within Python, intercept the act of assignment. For instance, suppose that I was obsessed with FORTRAN II, and decided that I wanted to print a warning, or raise an exception any time someone assigned an int to a variable whose name did not start with i,j,k,l