Changing Python code in the debugger

Is there a debugger that allows you to modify Python code during debugging?

In other words: an exception is thrown at runtime, the debugger stops, I change the code in any way I like, and tell the program to continue.

I know the problems with this approach, so function references will still point to old definitions if I redefine the function on the fly, etc. I am fine with this since I just want to make small corrections in very simple circumstances.

On the other hand, I am also interested in whether it is theoretically possible to allow changes to Python code without using these problems: i.e. somehow update all links to changed objects, etc. I am almost sure the answer to the second question is no, but if I am mistaken, I would like to know.

EDIT: if my goal is (changing the code interactively when an exception occurs and then executing it), it is possible without a debugger - this is also good. I do not need to use a debugger.

+5
source share
4 answers

Since you can change the contents of ordinary classes the way you want, at any time, there is no need to update references to objects: you simply update the class __dict__with new methods and other attributes.

: . -, , . , , ; , , , -, .

, : , . AFAIK Erlang " " .

+1

, pdb . , .

, , , . ( , . ), , .

, , . , , , , , , . .

( , "reload()", , , .)

+1
+1

Python

. " ". Python VM, , . - .

- ,

. , "" . , .

This is why debuggers are bad. It seems that they lead to muddy, obscure thinking. Too much to think about the debugger means too little to think about the real problem.

TDD is a much better investment. Small, manageable unit tests run quickly and provide convincing evidence that everything works.

http://en.wikipedia.org/wiki/Test-driven_development

0
source

All Articles