Is this possible in Python ?
Chad Netzer
cnetzer at mail.arc.nasa.gov
Thu May 15 15:21:07 EDT 2003
On Thu, 2003-05-15 at 05:13, Helmut Jarausch wrote:
> 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
As others have pointed out, you can fairly easily create objects that
implement this kind of behavior. Also, there is the Python debugger
(pdb module - comes standard with Python), for tracing and inspecting
live programs.
Furthermore, much modern software engineering practice prescribes
building your software in such a way as you don't have to ever do this
kind of debugging (the old "peek at variables and trace program flow",
that was prevalent before object-oriented programming was big, and when
assembly language debuggers were common). These days, good practice
suggests you design with testing suites (such as unit tests), and
"contracts" (often reduced to putting 'assert' statements throughout
your code to cause early failure when a bug is causing your program
state to go bad.)
I grew up using debuggers, and these days, I *never* use them. I simply
don't need to, because my software is (typically) pieced together from
small, well-tested components, with tests that scale up as the
complexity of the system scales.
If this interests you, please inquire further, and I'm sure people will
point you to more specific resources. In the mean time, look into
Python unittest module, and the buzzword compliant "Extreme Programming"
and "Agile Programming" methodologies)
--
Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)
More information about the Python-list
mailing list