Py3K idea: why not drop the colon?

Michael Hobbs mike at hobbshouse.org
Fri Nov 10 14:33:42 EST 2006


Ron Adam wrote:
> The faq also pointed out a technical reason for requiring the colon.  It makes 
> the underlying parser much easier to write and maintain.  This shouldn't be 
> taken to lightly in my opinion, because a simpler easer to maintain and more 
> reliable python parser means development time can be spent improving the 
> language in other areas instead of fixing parsing problems every time a new 
> feature is added that might be used in a conditional expression.
>   
Not to be too picky about it, but the FAQ was referring to editor 
parsers, not the parser used by Python itself. The Python parser could 
easily change its grammar to make the colon optional.

I find the editor parsing excuse to be weak since most editors tend to 
get hung up on Python code anyway, regardless of the colons. (Except for 
the ones that are specifically written to support Python, or are 
insanely programmable, like emacs.) In fact, I find that my editor 
usually gets confused when it comes across colons in dictionary literals 
or lambda expressions. If it just stuck to looking at the indentation, 
instead of trying to play off syntax tricks, it would behave much better.

- Mike




More information about the Python-list mailing list