Running Python IDLE from the command line to edit scripts

I tried many variations of this command: idle.py -e filepathbut it just launches IDLE, as usual, without opening any additional windows for editing and without throwing any errors.

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

+5
source share
7 answers

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

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

script "C:\file1.py" "C:\file2.py" , .bat . , .

+6

, , linux python , IDLE2 IDLE3 . , . , syslinks /usr/bin/path .

sudo ln -s idle-python3.1 idle3
sudo ln -s idle-python2.6 idle2

OP. script, :

idle3 abc123.py 

idle2 abc123.py

, "", 2- , .

+5

, main.py idelib (C:\Python33\Lib\idlelib), , python 3.3 , :

IDLE main entry point

Run IDLE as python -m idlelib

, python -m idlelib <script_to_edit> script . ,

3.3.3

+5

os. " win" .py :

start /MIN cmd /C c:\Python27\lib\idlelib\idle.py -e %1 %2 %3 %4 %5 %6

cmd . , . , , idle ().

+2

,
  "python3.5". : C:\Program Files\Python35\Lib\idlelib. . : idle -r file_name.py, idle file_name.py


start idle -r file_name.py ^&exit
+1

Python, Python. . , , - .

import fileinput
import os
os.chdir( os.path.join("c:\\","path") )
for file in os.listdir("."):
    for line in fileinput.input(file,inplace=0):
       if "search word" in line :
           line=line.replace("search word","new word")
           print line

( inplace=1 ). script Python script .

0

IDLE PATH.

, IDLE_PATH C:\Python27\Lib\idlelib

PATH ;%IDLE_PATH%; cmd 2 idle <file_name>, , . IPython ! , !idle test.py.

, -!

0

All Articles