Search code examples
pythonpython-idle

How to run a python script in IDLE using CMD prompt


I am wondering if there is a way to open a python script in IDLE run mode, (the equivalent of opening it with idle.exe {path} and pressing F5) or set it up so that if a .py file is open with IDLE it automatically runs it.

#Opens without IDLE GUI
python {path}
#Opens in IDLE, but in editor mode
@ECHO OFF
idle.exe {path_to_idle}

Solution

  • # Running script.py in idle
    idle.exe -r script.py
    

    You might consider using:

    # Inspect interactively after running script (see "python --help" from cmd)
    python -i script.py