Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you reload your Python source into the console window in Eclipse/Pydev?

Tags:

python

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.

like image 859
J. Peterson Avatar asked Jul 27 '09 22:07

J. Peterson


2 Answers

You can do it with Ctrl+Alt+Enter on the latest Pydev for details on what Ctrl+Alt+Enter provides as it can do a number of things related to the interactive console.

like image 93
Fabio Zadrozny Avatar answered Oct 21 '22 07:10

Fabio Zadrozny


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.

like image 20
Mirozell Avatar answered Oct 21 '22 08:10

Mirozell