citn
citn

Reputation: 1560

How to open python source files using the IDLE shell?

If I import a module in IDLE using:

import <module_name>
print <module_name>.__file__

how can I open it without going through the Menu->File->Open multiple-step procedure?

It would be nice to open it via a command that takes the path and outputs a separate editor like IDLE.

Upvotes: 1

Views: 2620

Answers (2)

Miki Tebeka
Miki Tebeka

Reputation: 13910

  • You can use ALT-M and write the name of the module in the popup box
  • You can use CTRL-O to open a file

Upvotes: 2

jcdyer
jcdyer

Reputation: 19165

I don't think IDLE will do it for you, but if you use Wing, you can mouse over the name of the module, and do a <Ctrl>-<Left Click>, or open the right click context menu on the module name, and select "Goto definition." Simple. You don't even have to know the module's file location; you just have to have it on your PYTHONPATH.

Limitation: It doesn't work if you add it to your PYTHONPATH using sys.path.append(). It has to be on the path that exists when the file is opened, though you can configure that on a per-project or per-file basis within Wing.

Upvotes: 0

Related Questions