You can open your .py file with IDLE and press F5 to run it.
You can open that same file with other editor ( like Komodo as you said ) save it and press F5 again; F5 works with IDLE ( even when the editing is done with another tool ).
I'm very glad you asked! I was just working on explaining this very thing in our wikibook (which is obviously incomplete). We're working with Python novices, and had to help a few through exactly what you're asking!
Command-line Python in Windows:
Save your python code file somewhere, using "Save" or "Save as" in your editor. Lets call it 'first.py' in some folder, like "pyscripts" that you make on your Desktop.
Open a prompt (a Windows 'cmd' shell that is a text interface into the computer):
start > run > "cmd" (in the little box). OK.
Navigate to where your python file is, using the commands 'cd' (change directory) and 'dir' (to show files in the directory, to verify your head). For our example something like,
> cd C:\Documents and Settings\Gregg\Desktop\pyscripts
try:
> python first.py
If you get this message:
'python' is not recognized as an
internal or external command, operable
program or batch file.
then python (the interpreter program that can translate Python into 'computer instructions') isn't on your path (see Putting Python in Your Path below). Then try calling it like this (assuming Python2.6, installed in the usual location):
> C:\Python26\python.exe first.py
(Advanced users: instead of first.py, you could write out first.py's full path of C:\Documents and Settings\Gregg\Desktop\pyscripts\first.py)
Putting Python In Your Path
Windows
In order to run programs, your operating system looks in various places,
and tries to match the name of the program / command you typed with some
programs along the way.
In windows:
control panel > system > advanced > |Environmental Variables| > system variables -> Path
this needs to include: C:\Python26; (or equivalent). If you put it at the front,
it will be the first place looked. You can also add it at the end, which is possibly saner.
Then restart your prompt, and try typing 'python'. If it all worked, you should
get a ">>>" prompt.
Python itself comes with an editor that you can access from the IDLE File > New File menu option.
Write the code in that file, save it as [filename].py and then (in that same file editor window) press F5 to execute the code you created in the IDLE Shell window.
Note: it's just been the easiest and most straightforward way for me so far.
If this helps anyone, neither "python [filename].py" or "python.exe [filename.py]" worked for me, but "start python [filename].py" did. If anyone else is experiencing issues with the former two commands, try the latter one.
What I just did, to open a simple python script by double clicking. I just added a batch file to the directory containing the script:
@echo off
python exercise.py
pause>nul
(I have the python executable on my system path. If not one would need include its complete path of course.)
Then I just can double click on the batch file to run the script. The third line keeps the cmd window from being dismissed as soon as the script ends, so you can see the results. :) When you're done just close the command window.
Navigate your file location just press Shift button and click file name. Click tab Open command window here and write in your command prompt python file_name.py
I have tried many of the commands listed above, however none worked, even after setting my path to include the directory where I installed Python.
The command py -3 file.py always works for me, and if I want to run Python 2 code, as long as Python 2 is in my path, just changing the command to py -2 file.py works perfectly.
I am using Windows, so I'm not too sure if this command will work on Linux, or Mac, but it's worth a try.
If you want to run the #'.py' file
just write in print() in your code to actually see it get printed.
Unlike python IDLE, you need to specify what you want to print using print() command.
For eg.
import os
os.getcwd()
a=[1,2,3,4,5]
name= 'Python'
# Use print() function
print(a)
print(name)