Python is readable
Thu Mar 15 16:18:14 CET 2012
On 3/15/2012 15:43, Robert Kern wrote:
> On 3/15/12 2:30 PM, Kiuhnm wrote:
>> On 3/15/2012 15:23, Duncan Booth wrote:
>>> Kiuhnm<kiuhnm03.4t.yahoo.it> wrote:
>>>> BTW, aren't those ':' redundant?
>>> They are required by the grammar, but in a sense you are correct. You
>>> modify Python's grammar to make the colons optional and still keep it
>>> unambiguous but that would make it harder for other tools (such as text
>>> editors or indeed humans) to understand.
>> Sorry, but I can't see how it would make it harder for humans to
>> understand. Are
>> there particular situations you're referring to?
> There were usability studies done on one of Python's indentation-based
> ancestors, ABC. Those studies found, empirically, that having the colons
> helped people read and understand the code faster.
Here's what Guido van Rossum writes about it:
"Python’s use of indentation comes directly from ABC, but this idea
didn’t originate with ABC--it had already been promoted by Donald Knuth
and was a well-known concept of programming style. (The occam
programming language also used it.) However, ABC’s authors did invent
the use of the colon that separates the lead-in clause from the indented
----> After early user testing without the colon, it was discovered that
the meaning of the indentation was unclear to beginners being taught the
first steps of programming. <----
The addition of the colon clarified it significantly: the colon somehow
draws attention to what follows and ties the phrases before and after it
together in just the right way."
If that passage is correct, those studies don't say that adding the
colon increases the readability, but that it makes more sense to
beginners who don't even know what indentation is.
More information about the Python-list