Py3K idea: why not drop the colon?

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sat Nov 11 02:09:39 CET 2006


On Fri, 10 Nov 2006 15:18:55 -0600, Michael Hobbs wrote:

> Ron Adam wrote:
>> It is also an outline form that frequently used in written languages.  Something 
>> python tries to do, is to be readable as if it were written in plain language 
>> where it is practical to do so.  So the colon/outline form makes a certain sense 
>> in that case as well.
>>   
> That is perhaps the most convincing argument that I've heard so far. 
> Indeed, I often find myself writing out colons when writing pseudo-code 
> out on paper. The reason, however, is usually because my indents don't 
> quite line up as perfectly on paper as they do in an editor. The colons 
> provide a form of backup separation for when my columns start to get 
> sloppy. (Natural language is actually filled with such redundancies in 
> order to compensate for sloppy handwriting.)

Er, natural language pre-dates handwriting by many tens or hundreds of
thousands of years. The redundancy of natural language has many reasons,
but compensating for sloppy handwriting is not one of them.


> This backup function 
> obviously isn't needed when a computer is taking care of the layout.

That word you use, "obviously", I don't think it means what you think it
means. There's nothing obvious about your conclusion to me.

while (this really long expression
    (which extends over multiple lines
    and contains many statements)
    some of which (like this one) contain
    nested bracketed terms such as (this
    expression here) but like all good 
    things) it eventually ends
    and we can get to the business
    of executing the while-block

Compare that to the version with a colon:

while (this really long expression
    (which extends over multiple lines
    and contains many statements)
    some of which (like this one) contain
    nested bracketed terms such as (this
    expression here) but like all good 
    things) it eventually ends:
    and we can get to the business
    of executing the while-block


Arguably, the parser might not find the first version any more difficult
than the second, but I know which one I'd rather read.

> My final argument against the colons is to simply try programming in 
> Ruby for a while and then come back to Python. I think you'll find that 
> programming without the colons just simply feels more "natural".

And maybe you're even correct. But one major reason of using the colon is
to make it easier for _inexperienced_ programmers. Your suggestion that
programming in Ruby for a while should be a prerequisite for making Python
easy to read is an interesting one, but not one that many people will
agree with. *wink*


-- 
Steven.




More information about the Python-list mailing list