简体   繁体   English

在断点的上下文中将多行代码发送到PyDev交互式控制台

[英]Send multiple line code to PyDev interactive console at the context of a breakpoint

I'm using Eclipse Luna 4.4.0 + PyDev 3.7.0. 我正在使用Eclipse Luna 4.4.0 + PyDev 3.7.0。

My goal is to execute a python script and being able to send commands to the console while stopped at a breakpoint, using its context and selecting several lines of code at once, with different indentations, like for loops, if statements, etc. This would be a similar debugging behavior as with MATLAB (selecting code and pressing F9), which I find really useful. 我的目标是执行一个python脚本,并能够在断点处停止时将其发送到控制台,使用其上下文并一次选择几行代码,并使用不同的缩进,例如for循环, if语句等。与MATLAB相似(选择代码并按F9),这是非常有用的调试行为。

If I press ALT + CTRL + Enter without selecting any code the script is executed within the interactive console. 如果我在不选择任何代码的情况下按ALT + CTRL + Enter ,则脚本将在交互式控制台中执行。 The execution indeed stops at the first breakpoint. 实际上,执行在第一个断点处停止。 I can inspect the variables, but the console does not prompt me for any input. 我可以检查变量,但是控制台不会提示我任何输入。 I can select and send commands with ALT + CTRL + Enter , but they are greyed out, and not interpreted at all. 我可以使用ALT + CTRL + Enter选择和发送命令,但是它们是灰色的,根本没有解释。 If I'm not stopped at a breakpoint, this method does not support blocks of code with different indentations, like for loops, when prompted for commands. 如果我没有在断点处停止,则此方法不支持在提示输入命令时使用具有不同缩进的代码块,例如for循环。

If I run a normal debug session, without pressing ALT + CTRL + Enter , I can stop at a breakpoint and have some interaction, like typing single commands (displayed in green, not in grey), but I cannot send several commands, and they need to have the right indentation. 如果运行正常的调试会话,而无需按ALT + CTRL + Enter ,则可以在断点处停止并进行一些交互,例如键入单个命令(以绿色显示,而不是灰色显示),但是我无法发送多个命令,它们需要正确的缩进。 Launching an interactive console at this point will result in a new console with a new context. 此时启动交互式控制台将产生具有新上下文的新控制台。

Is there any way to select and send a block of code to the interactive console while being stopped at a breakpoint, using the context at that moment?. 在此时使用上下文在断点处停止时,是否有任何方法可以选择并向交互式控制台发送代码块? Is it possible to do this with any other IDE? 是否可以使用其他任何IDE来执行此操作?

I've seen similar questions in SO like this question , or this answer , but this is still unclear to me. 我在SO中看到过类似的问题,例如这个问题这个答案 ,但是我仍然不清楚。

As it is now, it works at that as an interactive console -- so, the indentation really needs to be right with Ctrl+Alt+Enter, but if you use F2 instead, it should work better (as F2 is meant to fix the indentation and should do what you want)... 就目前而言,它可以作为交互式控制台来使用-因此,缩进确实需要使用Ctrl + Alt + Enter正确,但是如果使用F2,它应该会更好(因为F2可以解决缩进,应该做你想要的)

Reference: http://pydev.org/manual_adv_interactive_console.html 参考: http//pydev.org/manual_adv_interactive_console.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM