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

 

A Django site. this page was rendered by a django application in 0.01s 2012-02-13 17:02:05.523921. hosted by webfaction.