Tags: changing, color, command, commandprompt, error, example, foreground, message, printing, programming, prompt, python, pythonfor
changing color on the command prompt
On Programmer » Python
2,339 words with 2 Comments; publish: Wed, 26 Dec 2007 22:54:00 GMT; (20062.50, « »)
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
http://python.itags.org/q_python_13434.html
All Comments
Leave a comment...
- 2 Comments

- Hank wrote:
> 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
#1; Wed, 26 Dec 2007 22:55:00 GMT

- 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 <peter.python.itags.org.engcorp.com> wrote in message news:<3F4D34C5.150FD96E.python.itags.org.engcorp.com>...
> Hank wrote:
> > 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.python.itags.org.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
#2; Wed, 26 Dec 2007 22:57:00 GMT