Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Debugging: code editing on the fly

I am new to python and haven't been able to find out whether this is possible or not.

I am using the PyDev plugin under Eclipse, and basically all I want to find out is, is it possible to edit code whilst you're sitting at a breakpoint? I.e. Edit code whilst you're debugging.

It allows me to do this at present, but it seems to still be executing the line of code that previously existed before I made changes.

Also, are you able to drag program execution back like you can in VBA and C# for example?

If either of these are possible, how can I enable them?

like image 353
cOrOllArY Avatar asked Oct 23 '09 14:10

cOrOllArY


2 Answers

PyDev supports this to some extend since version 1.4.8, see the change notes and the corresponding blog entry.

like image 174
nikow Avatar answered Oct 22 '22 06:10

nikow


When you start a Python program, it will be compiled into bytecode (and possibly saved as .pyc file). That means you can change the source but since you don't "open" the source again, the change won't be picked up.

There are systems like TurboGears (a web framework) which detect these changes and restart themselves but that's probably going to confuse the debugger.

Going back in time also isn't possible currently since the bytecode interpreter would need support for this.

like image 40
Aaron Digulla Avatar answered Oct 22 '22 07:10

Aaron Digulla