how to modify code while debugging it without having to stop and then restart debugger
lycka at carmen.se
Wed Nov 9 14:27:46 CET 2005
> so how can i use python to debug code and change that code without having to restart the code.
I don't know how well the commercial GUIs, such as Wing IDE
manage to handle debugging. Perhaps that's worth looking into.
It's my impression that debugger support in Python is weaker
than e.g. VB, because Python programmers don't need and use
debuggers so much.
I think there are several reasons for this:
- It's easy to experiment with code in the interactive
- Python programs don't dump. There is rarely a need to put
a breakpoint at some known safe place and single-step from
there until it crashes, and then redo everything, trying to
find at what place before the crash you really had your bug.
You'll almost always get a controlled exception in Python.
- The tracebacks you get when exceptions appear are very
informative, and typically enough to spot the bugs more or
less at once. I debugged python programs I've never seen
before last night and today. There were maybe half a dozen
bugs, and in all cases, the tracebacks showed me exactly what
I needed to do to fix the problems at once.
- Due to Python's expressiveness, typical Python programs are
shorter and simpler than comparable programs written in
other languages. If you have spaghetti code, you really
need to single-step to understand what is going on. Python
code is typically well structured.
- With Python, it's common that people write unit tests
using e.g. the unittest or doctest libraries. With a test
driven approach as described in Extreme Programming, you run
your tests very often, with small changes in the code between
each test run.
- With object-oriented programming, it's easier to structure
your code so that each chunk of code (e.g. method) is
easy to understand. In other words, the divide and conquer
approach to problem solving works better.
I guess another reason is that Microsoft has put a lot of money
into making VB and friends user friendly. These products are
very much geared into accomodating beginners, and a nice looking
GUI has been a very high priority. For an open source tool such
as Python, where the people who drive development are the people
who need to use the tool, being beginner friendly isn't the top
priority (even though Python has succeeded well in that regard
anyway). Aspects such as stability and consistency in semantics
is considered much more important. (VB has a prettier GUI, but
Python is a much prettier language...)
More information about the Python-list