tags:

views:

342

answers:

2

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.

+1  A: 

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.

Mirozell
"Revert" just resets the text editor to the source file saved on disk. It does nothing to load the file into the Python interpreter running in the Eclipse console pane.
J. Peterson
sorry, misunderstood the question. Updated answer.
Mirozell
+1  A: 

You can do it with Ctrl+Alt+Enter on the latest Pydev (see: http://pydev.org/manual_adv_interactive_console.html for details on what Ctrl+Alt+Enter provides as it can do a number of things related to the interactive console).

Fabio Zadrozny