A Suggestion for Python Colon Syntax

William Djaja Tjokroaminata billtj at y.glue.umd.edu
Fri Dec 22 15:38:08 EST 2000

D-Man <dsh8290 at rit.edu> wrote:
: On Fri, Dec 22, 2000 at 06:42:11PM +0000, William Djaja Tjokroaminata wrote:


:> I am not too familiar with the parsing stuff.  However, in my simplistic
:> opinion, Python is not a free-form language like C or Perl.  Therefore,
:> probably it is reasonable for any parser to breaks a Python code first
:> into lines, even in backward parsing, instead of parsing it token by
:> token first.  In parsing backwards, can then it just detect first that the
:> line is at different indentation level rather than try to detect the
:> colon?

: If the parser (I believe you are referring to someone's emacs mode
: thing) used the indentation level to infer the structure, it would
: totally defeat the purpose.  The purpose of that parser is with the
: following input:

: if 1 :<enter>print "hello"

: To give the following result in the editor:

: if 1:
: 	print "hello"

: I use vim myself and rather like this feature in C/C++/Java modes.  It
: also handles the unindent when a } is typed.

: I for one rather like having the colon and I have more experience
: using C++, C, and Java than Python.


Well, I think there is not much support in making the colon optional.  I
use emacs, but it does not have the python mode (yet).  But the beauty of
Python is, in C or C++ I don't think I want to program without a
color-coding editor, but with Python, even in simple text mode, I can
program easily.  I guess I just have to install the python mode in emacs,
and based on the automatic indentation caused by the colon, probably the
colon will help me in coding (by automating the indent) rather than keep
giving me syntax errors from time to time.

I will start another thread about another suggestion (regarding the
dictionary), and I guess it indicates how useful Python to me is.



More information about the Python-list mailing list