The use of :
BJörn Lindqvist
bjourne at gmail.com
Sun Nov 28 16:10:31 EST 2004
In the faq, http://www.python.org/doc/faq/general.html#why-are-colons-required-for-the-if-while-def-class-statements,
it is stated that the colon is there "primarily to enhance readability
(one of the results of the experimental ABC language)." But can that
statement really be backed up? Has someone made a study or something?
I always thought the rule was "the less useless symbols, the higher
the readability." I.e:
if (a == b)
{
print a
}
is less readable than:
if a == b:
print a
Because it contains more non-significant symbols (, ), { and } that
"steal" the programmers attention. But consider
def f(x, y, z)
print x, y, z
to
def f(x, y, z):
print x, y, z
IMHO, the colon-less variant is more readable than the one with the colon.
--
mvh Björn
More information about the Python-list
mailing list