Keeping the Console Open with IDLE
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Fri Feb 20 10:26:09 EST 2009
En Fri, 20 Feb 2009 12:39:14 -0200, W. eWatson <notvalid2 at sbcglobal.net>
escribió:
> Catherine Heathcote wrote:
>> you need to open a dos prompt before doing the steps above. Go to
>> start->run and hit "cmd" <enter> without the quotes.
> Something is amiss here. There's the MS Command Prompt, which I'm
> looking at right now. Yes, it has cd, and so on. I'm also looking at the
> Python command line window. It allow one to run interactively.
Open a command prompt ("CMD", "Console"), that black window you were
looking at.
Use the cd command to change directory to wherever your Python script is
saved.
Execute "python -V" (without the quotes). You should get a response,
including the Python version number. If you get an error like "command not
found" or similar, you'll have to use the whole path to python.exe -- try
with "c:\python25\python -V" (again, no quotes).
Once you know how to launch Python, you can:
a) Enter the interactive interpreter: Just launch Python as above but
without the -V argument. The prompt is now >>>
You can type Python expressions and the interpreter evaluates them. You
type 2+3, the interpreter answers 5; you type len("abc"), the interpreter
answers 3...
b) Or, from the command prompt, you can execute a script by launching
Python the same way as above, passing the script name as an argument:
c:\foo>python script_name.py
This is what you were looking for - in case of syntax errors or something,
you can see the output on the console. It stays open because it was open
*before* you launched Python. Just keep the window open.
See http://docs.python.org/using/windows.html for more info. If Python
doesn't start just by typing "python", you may want to set your PATH
environment variable as described there.
--
Gabriel Genellina
More information about the Python-list
mailing list