Py3K idea: why not drop the colon?

Steve Holden steve at holdenweb.com
Mon Nov 13 16:55:52 EST 2006


Michael Hobbs wrote:
> Carsten Haese wrote:
>> On Sat, 2006-11-11 at 23:18 -0800, Doug wrote:
>>   
>>> Michael Hobbs wrote:
>>>     
>>>> I think the colon could be omitted from every type of compound
>>>> statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything?
>>>>
>>>> Thanks,
>>>> - Mike
>>>>       
>>> It is a very good idea as the colon is technically redundant (not
>>> necessary for parsing, aside from one liners) and actually hurts
>>> readability (and writeability).  The "evidence" people cite for the
>>> advantage of using a colon is research done by users of the ABC
>>> language, python's predecessor.  They forget that A) that was like 20
>>> years ago,
>>>     
>> Research being old does not automatically invalidate it. Old research is
>> invalidated by newer research that invalidates it.
>>
>>   
> No, old research does is not automatically invalidated, but 
> out-of-context research is. I'm sure there's research somewhere proving 
> that code written in ALL UPPERCASE is preferable, since it makes 
> punched-cards easier to read by humans. Python 1.0 may have been a nice 
> language for "newbies", with a lot of similarities to ABC, but there has 
> been a lot of evolution since then. Sure, it's still very easy to teach 
> basic Python, but if you're concerned about readability, take a look at 
> any real-world Python app or library. You'll find it's filled with 
> things such as "__getattr__", "__repr__", "__nonzero__", and 
> "super(MyClass, self).__init__()". Hardly newbie stuff.
> 
In fact most Python doesn't use such constructs, though I'll admit the 
occasional __init__ is more or less inevitable once you start using the 
object-oriented features more than casually.

You are talking about some fairly advanced introspection, and the double 
under naming conventions were chosen precisely to indicate that some 
fairly special voodoo was being invoked. Readability is relative, and by 
the time you have the need to use the magic names they probably won't 
interfere with your reading overmuch.

> I think waving the banner of ABC simplicity in the context of Py3K is 
> about as applicable as complaining that an RSS aggregator isn't written 
> in assembly. (An RSS aggregator is so far beyond being CPU-bound that 
> it's pointless to argue which language it should be written in.)

I might take your admittedly cheerful wibbling a little more seriously 
if, rather than trying to argue that the ABC study isn't valid for 
Python, you came up with some sort of result that supported your ideas 
(which I accept you aren't really concerned to promote: does this make 
you a troll?)

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list