[IronPython] OnVarChanged

Brandon Furtwangler furtwan1 at msu.edu
Tue Jun 20 18:53:44 CEST 2006

How fine grain do you need change notifications?  you could just store the
pre-execute value of a, and after each python Execute you could check that
the pre-a is the same as a.

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of John Mancine
Sent: Tuesday, June 20, 2006 12:25 PM
To: users at lists.ironpython.com
Subject: [IronPython] OnVarChanged

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


users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list