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)?
Just add IDLE's path to your
PATH
environment variable.For example I created an environment variable called
IDLE_PATH
and set the value toC:\Python27\Lib\idlelib
Then in my
PATH
variable I added;%IDLE_PATH%;
and open a new cmd prompt or in console2 just open a new tab and runidle <file_name>
to open the file, you will be able to do this from any directory. In IPython console add an!
before the command, for example!idle test.py
.Congrates, Now you're a python pimp!
Make a new text file, and put something like this in it:
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.
you can just program in Python to edit your Python files. A simple example. say you want to search for a word and then replace it with something else.
(use
inplace=1
to do in place editing.). Then save and run the script as normal Python script using the interpreter.Please forgive me for bumping such an old thread, but I've been teaching myself linux and python with the help of the community, and was trying to figure out how to invoke IDLE2 and IDLE3 from the command line. I came across this post some of the solutions seemed a bit complicated for my application. Then it occurred to me that I could just put syslinks in the /usr/bin/ path for each.
to address the OP. From the directory the script is located, type:
or
I'm just so damned happy that I finally had a "light bulb" go off that I wasn't going to let a 2 year old post stop me from posting my solution.
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:
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 comandThis is also documented on the changelog of the version 3.3.3
Rarely the native os is useful. I created a 'win batch file, in the folder with my .py files:
This can open up to six files from cmd line in one shot. Just type the name of the batch file, followed by from zero to six filenames. Also if one or more files you specify are not found, idle opens these as new document(s).