Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

starting Python IDLE from command line to edit scripts

I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors.

So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?

like image 936
Ponkadoodle Avatar asked Feb 26 '10 23:02

Ponkadoodle


2 Answers

You need to do as stated in the main.py file of the idelib folder (C:\Python33\Lib\idlelib), at least on the python 3.3 version explains that:

IDLE main entry point

Run IDLE as python -m idlelib

So with python -m idlelib <script_to_edit> you will be able to open and edit the script with idle. I haven't checked with previous versions but it could be the same comand

This is also documented on the changelog of the version 3.3.3

like image 118
llrs Avatar answered Oct 04 '22 18:10

llrs


Make a new text file, and put something like this in it:

C:\Python26\Lib\idlelib\idle.pyw "C:\file1.py" "C:\file2.py"

In your actual script, you'll replace "C:\file1.py" and "C:\file2.py" with your files' paths, save as a .bat, and then launch it. That should do what you want.

like image 36
Redouane Zait Avatar answered Oct 04 '22 18:10

Redouane Zait