[IronPython] OnVarChanged

John Mancine john at emergentlifetech.com
Tue Jun 20 18:25:09 CEST 2006


I realize this is likely woefully naïve but I thought I'd ask anyhow. 

I have a very specific case in my project where I would really like to know
when a variable inside IronPython changes. Basically when I do this:

pythonEngine.Execute("a = 3"); // Or something more complex that ends up
changing global var 'a'

I am looking for a way to be notified when 'a' has been assigned to a new
value. This seems to be pretty simple for the Set/GetGlobal() calls but what
about code that is inside of the Execute() block? Where could I look at
adding some code myself such that I can add these hooks? I have dug through
some of the code to find a place to add a hook but I couldn't seem to find
anything clear cut.

Again, I realize this is pretty simplistic and also painfully slow for any
moderate scripting but I have a very specific case where I would like some
widgets in C# to respond to when a variable has changed. (The watchwindow in
visual studio would be a good parallel of what I'm needing to do -- ie. show
a new value has been set for a particular value you are watching).

Thanks!
John




More information about the Ironpython-users mailing list