assignment hook

paul.lafollette at paul.lafollette at
Sat Sep 23 19:58:14 EDT 2006

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,m, or n.

If assigment were an operator, I could, perhaps,  subclass
something and override the (non-existant)__assign__ method
to find the name of the variable and the type of the assigned
object, but it ain't so I can't.

My guess is that it is simply impossible, but if it IS possible,
I would love to know how to do it.  Thank you for your time
and expertise.


Your task it is, amid confusion, rush, and noise, to grasp the lasting,
calm, and  meaningful, and finding it anew, to hold and treasure it.
-Paul Hindemith-

Paul S. LaFollette, Jr.
Temple University
CIS Department
paul.lafollette at

+1 215 204 6822

More information about the Python-list mailing list