[英]How do you reload your Python source into the console window in Eclipse/Pydev?
In other Python IDEs (PythonWin and Idle) it's possible to hit a key and have your current source file window reloaded into the console. 在其他Python IDE(PythonWin和Idle)中,可以按下一个键并将当前的源文件窗口重新加载到控制台中。 I find this useful when experimenting with a piece of code;
在尝试一段代码时,我发现这很有用; you can call functions from the console interactively and inspect data structures there.
您可以从控制台以交互方式调用函数并在其中检查数据结构。
Is there a way to do this with Eclipse/Pydev? 有没有办法用Eclipse / Pydev做到这一点?
So far I've been making do with this hack in my source file: 到目前为止,我一直在处理源文件中的此hack:
def relo():
execfile("/Path/To/Source.py", __builtins__)
I call relo()
in the console after I save changes to the source. 将更改保存到源代码后,我在控制台中调用
relo()
。 But I'd much rather just tap a key. 但是我宁愿只是点击一个键。 I'm using pydev 1.4.7.2843.
我正在使用pydev 1.4.7.2843。
This is somewhat related to this question, but I want to just reload the whole source file. 这与这个问题有些相关,但是我只想重新加载整个源文件。
Use the revert option on the File menu. 使用文件菜单上的还原选项。
You can bind a key to it in Windows > Preferences > General > Keys. 您可以在Windows>首选项>常规>密钥中将密钥绑定到它。
Edit: 编辑:
The reload(module) function will update packages in the interactive console. reload(module)函数将在交互式控制台中更新软件包。 It's built in for python 2.x and in the imp module for 3.x.
它内置于python 2.x和3.x的imp模块中。 Python docs link: http://docs.python.org/3.1/library/imp.html?#imp.reload
Python文档链接: http : //docs.python.org/3.1/library/imp.html?#imp.reload
Couldn't find a way to run it by hotkey, I'd like to know if you find a way. 无法找到通过热键运行它的方法,我想知道您是否找到一种方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.