Keeping the Console Open with IDLE

W

W. eWatson

I'm using IDLE for editing, but execute programs directly. If there are
execution or "compile" errors, the console closes before I can see what it
contains. How do I prevent that?
--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 
M

Matimus

I'm using IDLE for editing, but execute programs directly. If there are
execution or "compile" errors, the console closes before I can see what it
contains. How do I prevent that?
--
                                W. eWatson

              (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
               Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

                     Web Page: <www.speckledwithstars.net/>

Open a console window and type in the name of the script rather than
just double clicking on it. Or, you can terminate your script with a
'raw_input("press enter to quit")'.

Matt
 
D

David Smith

W. eWatson said:
I can open the Python command line from Start, but how do I navigate to
the folder where the program is?

I'm not sure whether I should feel old or write a smart alec comment --
I suppose there are people in the world who don't know what to do with a
command prompt....

Assuming a Windows system:

2. Type 'cd ' (as in Change Directory) in the command prompt window (w/o
the single quote characters)
3. Drag/drop the folder containing your python script to your command
prompt window
4. Hit enter in your command prompt window.
5. Type python my_script_name.py to execute my_script_name.py.

--David
 
W

W. eWatson

I'm not sure whether I should feel old or write a smart alec comment --
I suppose there are people in the world who don't know what to do with a
command prompt....

Assuming a Windows system:

2. Type 'cd ' (as in Change Directory) in the command prompt window (w/o
the single quote characters)
3. Drag/drop the folder containing your python script to your command
prompt window
4. Hit enter in your command prompt window.
5. Type python my_script_name.py to execute my_script_name.py.

--David
If I enter just cd, then it tells me cd is not defined. If I enter
c:/python25, it tells me I have a syntax error at c in c:. The title of the
black background window I have up with a >>> prompt shown in it is
"Python(command line)". Maybe this isn't the real Python console window?

What I want is that if I execute the program by double clicking on its name
to display the console window with the program or syntax errors shown
without it closing in a split second. Putting read_raw in it doesn't work,
since some error prevents it from ever being seen.

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 
C

Catherine Heathcote

W. eWatson said:
If I enter just cd, then it tells me cd is not defined. If I enter
c:/python25, it tells me I have a syntax error at c in c:. The title of
the black background window I have up with a >>> prompt shown in it is
"Python(command line)". Maybe this isn't the real Python console window?

What I want is that if I execute the program by double clicking on its
name to display the console window with the program or syntax errors
shown without it closing in a split second. Putting read_raw in it
doesn't work, since some error prevents it from ever being seen.

you need to open a dos prompt before doing the steps above. Go to
start->run and hit "cmd" <enter> without the quotes.
 
W

W. eWatson

W. eWatson said:
If I enter just cd, then it tells me cd is not defined. If I enter
c:/python25, it tells me I have a syntax error at c in c:. The title of
the black background window I have up with a >>> prompt shown in it is
"Python(command line)". Maybe this isn't the real Python console window?

What I want is that if I execute the program by double clicking on its
name to display the console window with the program or syntax errors
shown without it closing in a split second. Putting read_raw in it
doesn't work, since some error prevents it from ever being seen.
Whoa! What's going on here? I just looked at About IDLE, and it shows 1.2.2,
but yet the second edition of Learning Python talks about going to 2.3 as
the book is about to go to press, 2004. I thought IDLE came bundled with
Python. I have Py 2.5. 1.2.2??? Puzzled.

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 
G

Gabriel Genellina

Whoa! What's going on here? I just looked at About IDLE, and it shows
1.2.2, but yet the second edition of Learning Python talks about going
to 2.3 as the book is about to go to press, 2004. I thought IDLE came
bundled with Python. I have Py 2.5. 1.2.2??? Puzzled.

IDLE is a separate product; the version of IDLE that comes with Python
2.5.4 is 1.2.4
 
W

W. eWatson

Gabriel said:
IDLE is a separate product; the version of IDLE that comes with Python
2.5.4 is 1.2.4
Where do I get 2.x.x, or the latest?

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 
W

W. eWatson

Catherine said:
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.

If I write a simple python program with just raw_input, by clicking on the
file name, I get a window with the the title "\Python25\pythonexe" that
shows the prompt. If I deliberately put a syntax error in the program, and
run it by clicking the file, then A window appears and disappears so quickly
that I have no idea what it said. How do I keep that window up?

Which, if any, of these is the real Python console? What is the window
called in the example I gave with raw_input?

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 
C

Catherine Heathcote

W. eWatson said:
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.

If I write a simple python program with just raw_input, by clicking on
the file name, I get a window with the the title "\Python25\pythonexe"
that shows the prompt. If I deliberately put a syntax error in the
program, and run it by clicking the file, then A window appears and
disappears so quickly that I have no idea what it said. How do I keep
that window up?

Which, if any, of these is the real Python console? What is the window
called in the example I gave with raw_input?

Run the program from within the MS command line, not by double clicking it.
 
G

Gabriel Genellina

Where do I get 2.x.x, or the latest?

You may update your Python version to 2.5.4 (the latest release in the 2.5
series). Then IDLE will report 1.2.4. They are separate products, their
version numbers are uncorrelated.
 
G

Gabriel Genellina

Catherine Heathcote wrote:
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.
 
W

W. eWatson

Catherine said:
Run the program from within the MS command line, not by double clicking it.
Shirley, you jest? DOS? To do this? How ugly. I barely recall the DOS
commands. I get to drill my way down 4 levels of folders. What DOS cmd
allows one to list only folders?

Still, why would one design a window that disappears, when it has useful
data in it? I see that if I click on the window, it has properties, width,
height, etc.

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 
W

W. eWatson

Gabriel said:
You may update your Python version to 2.5.4 (the latest release in the
2.5 series). Then IDLE will report 1.2.4. They are separate products,
their version numbers are uncorrelated.
Ah, I see, the book is referring to version 2.3 of Python and not IDLE.

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 
D

David Smith

W. eWatson said:
If I enter just cd, then it tells me cd is not defined. If I enter
c:/python25, it tells me I have a syntax error at c in c:. The title of
the black background window I have up with a >>> prompt shown in it is
"Python(command line)". Maybe this isn't the real Python console window?

What I want is that if I execute the program by double clicking on its
name to display the console window with the program or syntax errors
shown without it closing in a split second. Putting read_raw in it
doesn't work, since some error prevents it from ever being seen.

What I meant was open open the command prompt, type cd, space, DO NOT
hit enter yet. Drag the folder with your script into the command prompt
window. Then go to the command prompt window and hit enter. This
should compose a command similar to the following:

C:\Documents and Settings\user> cd "C:\Documents and Settings\user\My
Documents\My Project"

C:\Documents and Settings\user\My Documents\My Project> _

--David
 
C

Catherine Heathcote

W. eWatson said:
Shirley, you jest? DOS? To do this? How ugly. I barely recall the DOS
commands. I get to drill my way down 4 levels of folders. What DOS cmd
allows one to list only folders?

Still, why would one design a window that disappears, when it has useful
data in it? I see that if I click on the window, it has properties,
width, height, etc.

Thats programming. Whaterver the language, you will need to be
comfortable with the CLI of your operating system.
 
W

W. eWatson

David said:
What I meant was open open the command prompt, type cd, space, DO NOT
hit enter yet. Drag the folder with your script into the command prompt
window. Then go to the command prompt window and hit enter. This
should compose a command similar to the following:

C:\Documents and Settings\user> cd "C:\Documents and Settings\user\My
Documents\My Project"

C:\Documents and Settings\user\My Documents\My Project> _

--David
Ah, I thought I'd be clever and do a copy on the path name in the address
area at the top of the folder. That doesn't work. I'm quite surprised though
that one can do the drag as you say. But, hey, it works. Thanks. I wonder
what else non-DOS things can be done in it?

--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 
G

Gabriel Genellina

Shirley, you jest? DOS? To do this? How ugly. I barely recall the DOS
commands. I get to drill my way down 4 levels of folders. What DOS cmd
allows one to list only folders?

After executing these two commands, pressing TAB will auto-complete
matching filenames/directories:

reg add "HKLM\Software\Microsoft\Command Processor" /v CompletionChar /t
REG_DWORD /d 9

reg add "HKLM\Software\Microsoft\Command Processor" /v PathCompletionChar
/t REG_DWORD /d 9

(Overwrite the previous value, if exists). This is a global change and the
logged on user must have administrative rights to modify the registry.
Unprivileged users must use HKCU instead of HKLM.
 
M

MRAB

Catherine said:
Run the program from within the MS command line, not by double clicking it.
Or create a .bat file containing the commands to run the Python program,
ending with the command "pause", which will wait for you to press a key
when the program has quit.
 
W

W. eWatson

W. eWatson said:
Ah, I thought I'd be clever and do a copy on the path name in the
address area at the top of the folder. That doesn't work. I'm quite
surprised though that one can do the drag as you say. But, hey, it
works. Thanks. I wonder what else non-DOS things can be done in it?
Well, there is a difficulty with this method. The path is very long, and one
must change the property width of the window. However, putting the name of a
long py file further complicates this.

The negative surprise here is that I'm trying to avoid executing the program
in IDLE, because I'm told elsewhere it produced erroneous error msgs. They
are exactly the same here. I'll take this up on another thread.



--
W. eWatson

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

Web Page: <www.speckledwithstars.net/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top