A Suggestion for Python Colon Syntax
fredrik at effbot.org
Thu Dec 21 18:26:14 CET 2000
"William Djaja Tjokroaminata" wrote:
> However, a lot of time when I ran my Python program, I got syntax
> error, because I forgot to put colon (:) after my if (or for, etc.) clause.
> My question is, is the colon really necessary, syntactically, in Python?
Short answer: The colon isn't there for the computer, it's
there for human readers. Just like the colons in your post:
> My suggestion is as follows:
> 1) If the if (or for, etc.) clause is followed by a block, then the colon
> is optional (for backward compatibility):
> if condition is true
(Using colons and indentations in the same way as in other written
languages is just one of many ideas Python has borrowed from the
ABC language: http://www.cwi.nl/~steven/abc )
Longer answer: ... nah, I'll leave that to the "while true" crowd.
I'm sure they'll keep you entertained until the end of next year!
Happy holidays, everyone!
More information about the Python-list