changing color on the command prompt

H

Hank

Hi,

does anyone know how to change the foreground color of the command
prompt through python?

For example if i was printing out an error message, I would like it to
be red where the normal text color is white.

Thanks
 
F

Fernando Perez

Hank said:
does anyone know how to change the foreground color of the command
prompt through python?

For example if i was printing out an error message, I would like it to
be red where the normal text color is white.

You may want to look at ipython (http://ipython.scipy.org), which does that
(and much more).

best,

f
 
H

Hank

Sorry I wasn't being clear enough.

I meant the prompt for Windows operating system C:>. And by error
messages i just mean printouts like
print "Error in Process"

If its just an environment variable, i should be able to change it,
print it out and change it back to the original color right?

Anyone know which variable i have to modify?

Thanks



Peter Hansen said:
Hank said:
does anyone know how to change the foreground color of the command
prompt through python?

For example if i was printing out an error message, I would like it to
be red where the normal text color is white.

The question is underspecified/unclear.

1. What operating system?

2. By "command prompt", do you just mean the console, where text appears,
or do you really mean the *prompt* for the operating system, which under
Linux is usually something like "[user@host]#" and which under Windows
is usually something like "C:\>"?

3. Now you mention error messages... that implies you just mean changing
the color of your program's output.

If you mean the actual *prompt*, you need to change the right environment
variable, which usually needs a separate script.

If you mean the console text color, check the archives for the last couple
of days for responses to a similar question (search for "ansi.sys" perhaps).

-Peter
 

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,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top