how to modify code while debugging it without having to stop and then restart debugger

Mike Meyer mwm at mired.org
Thu Nov 10 16:28:44 EST 2005


Magnus Lycka <lycka at carmen.se> writes:

> Mike Meyer wrote:
>> In that case, you're using the wrong IDE. I run the Python interpeter
>> inside of Emacs. I edit my code in another buffer. In the source code
>> buffer, I hit M-C-x, and the current version of the function I'm
>> currently editing gets sent to the interpreter. Reload is pretty easy
>> as well - C-c RETURN, and the module I'm editing gets reloaded.
>
> As far as I understand, the OP wanted to do this while single-stepping
> through the program he's editing. While this might work as a kind of
> exploration, it's probably not an optimal development strategy. It
> might be difficult to predict how the program will run the next time
> if you manipulate it during execution.

Yes, that's what he wanted. I was pointing out that there are
alternatives between "changing the function while you're debugging it"
and "retyping the function completely at the interactive prompt."

> I think test-driven development as described e.g. in my EPC presentation
> last year is more rewarding: http://www.thinkware.se/epc2004test/
> (See e.g. the log.html)

Depends on what you're doiing. If you know the subject area well
enough that you casn design all the objects and methods in advance so
you can write your unit tests, then this is indeed very rewarding.

If, on the other hand, you are doing something where you don't have a
clear understanding of what all the components are, and how they
interact, then it's more important to try things out to gain that
understanding than it is to have tests for components or methods that
you may well discard or morph beyond recognition tomorrow. The dynamic
nature of Python, coupled with the bundled interactive interpreter,
makes it particularly good for this type of programming.

> I guess it's a bit like driving an old crappy car, and then getting
> into a new Toyota. I can understand that it seems strange not to
> have the trunk filled with tools if you're about to take a long trip,
> but it's probably a mistake to think that this will make the journey
> with the Toyota more problematic than the trip would have been with
> a car that you need to repair every now and then.

Nice analogy.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list