[Tutor] RE: Tutor digest, Vol 1 #2 - 4 msgs

Tim Peters tim_one@email.msn.com
Tue, 9 Mar 1999 02:54:17 -0500


[Alan Gauld]
> ...
> I've been programming for about 15 years in C, C++, awk,
> Smalltalk, Lisp and Delphi.(Oh and COBOL but I try to forget
> that...)
>
> Anyway, My point for a Python tutorial:
>
> Explain the colon!!! It gets a passing mention in Lutz's book,
> none at all in Watter's book. It took me (as an experienced
> programmer) at least half an hour to figure out how/when
> the colon should be used(mainly by browsing the demo code)
> a beginner to programming with no concept of a 'block of
> code' will be baffled IMHO.

Alan, it's probably your very *experience* that gets in the way here.  No
kidding!  The colons aren't syntactically necessary, and you're experienced
enough to at least inuit that.

Python's most direct predecessor was a language called ABC, designed at CWI
in the Netherlands (Guido's former employer, and where Python began too).
ABC was a research project aiming at computer first-timers, and all aspects
of its design were subject to formal usability studies.  After a few
iterations, what they discovered is that "begin/end" blocking constructs
confused complete newbies, but using indentation for blocking didn't --
provided that the block's opening line ended with a colon.  We can speculate
about *why* that might be (and David's analogy with outlines sounds good to
me -- except that outlines don't usually have colons <wink>), but the fact
is that's what the studies discovered empirically.

BTW, I can tell you from my own experience that you wouldn't like ABC.  It
catered to newcomers so relentlessly that many aspects of it plain got in
the way for experienced programmers.  The trailing colon isn't one of those,
though; over time I predict you'll grow quite fond of it.

historically y'rs  - tim