We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

Why are colons required for the if/while/def/class statements?

The colon is required primarily to enhance readability (one of the results of the ABC language research project). Consider this:

    
if a == b
    print a

versus

    
if a == b:
    print a

Notice how the second one is slightly easier to read. Notice further how a colon sets off the example in the second line of this FAQ answer; it’s a standard usage in English.

Another minor reason is that the colon makes it easier for editors with syntax highlighting; they can look for colons to decide when indentation needs to be increased instead of having to do a more elaborate parsing of the program text.

CATEGORY: general design