简体   繁体   中英

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. 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?

So far I've been making do with this hack in my source file:

def relo():
    execfile("/Path/To/Source.py", __builtins__)

I call relo() in the console after I save changes to the source. But I'd much rather just tap a key. I'm using pydev 1.4.7.2843.

This is somewhat related to this question, but I want to just reload the whole source file.

您可以在最新的Pydev上使用Ctrl + Alt + Enter来进行操作,以获取Ctrl + Alt + Enter提供的内容的详细信息,因为Ctrl + Alt + Enter可以完成许多与交互式控制台相关的操作。

Use the revert option on the File menu.

You can bind a key to it in Windows > Preferences > General > Keys.

Edit:

The reload(module) function will update packages in the interactive console. It's built in for python 2.x and in the imp module for 3.x. Python docs link: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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