Is this possible in Python ?

Paul Watson pwatson at redlinec.com
Thu May 15 12:15:09 EDT 2003


It sounds like what you seek is more a function of the debugging or
interactive environment than it is source code.  When you "write" the line
"monitor a," is it in the source code or into an interactive debugging
session command prompt?

"Helmut Jarausch" <jarausch at igpm.rwth-aachen.de> wrote in message
news:3EC38453.1090104 at igpm.rwth-aachen.de...
> 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