Is this possible in Python ?

Helmut Jarausch jarausch at igpm.rwth-aachen.de
Thu May 15 08:13:07 EDT 2003


Carel Fellinger wrote:
> On Thu, May 15, 2003 at 10:03:55AM +0200, Helmut Jarausch wrote:
> ...
> 
>>Given a program with assignments like
>>a=b+a
>>one can say either
>>monitor 'a' on the left
>>or
>>monitor 'a' on the right.
> 
> 
> In python2.2 and up you can encapsulate such behavior in a class:
> 
>     class C(object):
>         def __init__(self, a=0):
>             print "init a"
>             self.set_a(a)
> 
>         def get_a(self):
>             print "right-monitor-a"
>             return self._a
>     
>         def set_a(self, value):
>             print "left-monitor-a"
>             self._a = value
>     
>         a = property(get_a, set_a, None, "monitor a")
> 
>     b = 1
>     c = C()
>     c.a = b + c.a

Thanks for this reply.

But it doesn't solve the problem.
The trick in Simscript was

You just write
a= b+c
d=2*a

then some time later you want to monitor the variables,
e.g. for debugging
and with changing any source line
you just enter these monitoring functions and
activate them.
Then whenever 'a' is accessed that's recognized
and these monitoring functions are invoked.



-- 
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany





More information about the Python-list mailing list