changing color on the command prompt

Peter Hansen peter at engcorp.com
Wed Aug 27 18:46:29 EDT 2003


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 at 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




More information about the Python-list mailing list