开发者

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 ab开发者_运维百科le 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?


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


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.


You can run arbitrary commands in the console during the breakpoint. For my needs, this typically achieves the same purpose as coding live, although I do wish it were as elegant as simply using the editor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜