开发者

Python and Eclipse: How to use interactive console after running a module, with the module variables and functions

Let's consider 3 situations:

1) I write a pyhon module in Eclipse (pydev) and run it Ctrl-F11. The module runs and I don't have any control or access (AFAIK) to the module variables and functions.

2) I have defined a python interpreter as an external tool in Eclipse, so I can run it within Eclipse. It works fine, but it does not have tab completion.

3开发者_开发技巧) I open my module with python IDLE (not eclipse) and press f5 (run). It runs on the IDLE opened window and when it finishes I have all the variables and functions form the module to play with.

So I have 2 questions: a) how to enable, if possible, tab completion in python interpreter in Eclipse? If it's not possible, do I have any alternative to standard Python interpreter?

b) I would like to run step 1) and then be able to continue developing / testing with python interpreter, just like I do with IDLE, but all inside Eclipse. Any suggestion?

Thanks in advance


Not sure how much has changed since the question was asked, but it's now possible to get code completion in the debug console (as of PyDev 1.6.0 according to http://pydev.org/manual_adv_debug_console.html, I'm on PyDev 2.8.1, Eclipse 4.3.0)

  • Set a breakpoint in the code, on an executable statement (even just print('') or True). Double clicking on the grey vertical bar to the left of the code should do it.
  • Run in debug mode with F11
  • Eclipse may prompt to switch to the Debug Perspective; either way, the Console should be visible
  • You should now be able to click in the Console pane and begin interactive debugging with code completion, even after a traceback. (Ctrl+Space works for me.)

Be aware that multi-line statements won't work unless they're split on : or /:

Update in 1.6.0: commands are evaluated on each new line unless the line starts with ' ' or '/t' or ends with ':' or '/' (so, for entering multi-line statements, the input must be entered properly respecting those limitations).


If you run it as a debug operation in Eclipse, you should be able to set a breakpoint, and you can then examine variables, etc. But you can evaluate random python scripts via the watch functionality.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜