kid wants to know more about color on the screen

Terry Reedy tjreedy at
Sat Jun 12 19:03:10 CEST 2004

"Doug Mitchell" <jmjm at> wrote in message
news:FMCyc.61975$8k4.1338501 at
> Dear Group,
> My son who is in grade 7 has *just* started going through the book
> for the Absolute Beginner" by Michael Dawson. He and I have no
> experience. He is beginning this on an old win 95 computer with Python
2.2 I
> think.

Congratulations to both of you.

> He is getting a bit frustrated with color coding.

This is a post-beginner subject that I think would best be skipped for now.
But I know, kids like color as much or even more than adults.

> For example in Chapter 2 page 18 and 19 Mr. Dawson describes a more fancy
> way of printing "Game Over" on the screen.  According to *him*...
> When I type the command:     print "Program 'Game Over' 2.0"
>                                               print \
> Instead of getting the second "print" to turn orange, like it's supposed
> when you type in a command, it just stays black. And when its time to
> actually run the program, Python just prints out Program Game Over 2.0
> instead of the fancy large text like that is shown in the book.

I've have never seen the book so I can only give comments similar to
Standard Python by itself knows nothing of colors and fonts.  The print
statement sends characters to the the file stream called stdout (for
standard output) which usually goes the the terminal and appears in
whatever font and color the terminal is set to.  So Dawson had to specify
something extra to get extra control.

> Later on he says that strings within quotes will be green as expected and
> then all of a sudden on the next line it will stay black :(. And when he
> does a run script there will be a syntax error as Python wont recognize
> 'black' string but then on another occasion the 'black' will run ok :(.

Some program editors do something extra to get different portions of the
program displayed in different colors so the programmer can pick them out m
ore easily.  In the one 'he' (Dawson or your son?) used, string literals
are apparently green.  String literals denoted by a ' ' pair or a " " pair
may not contain a newline (carriage return to you probably), which is to
say, cannot continue across more than one line.  So, if one types:

text = "Something to display
when the monster dies"

the editor might turn 'Something to display' green, but if it knows about
Python, it will leave 'when the monster dies' black because it cannot be
part of the string on the previous line.  The black rather than green says
that something is wrong, and when you try to execute the above, Python says

Terry J. Reedy

More information about the Python-list mailing list