Grouping code by indentation - feature or ******?

Robert Kern rkern at ucsd.edu
Fri Mar 25 20:38:37 CET 2005


James Stroud wrote:
> On Friday 25 March 2005 08:39 am, Ivan Van Laningham wrote:
> 
>>As far as grouping by indentation goes, it's why I fell in love with
>>Python in the first place.  Braces and so on are just extraneous cruft
>>as far as I'm concerned.  It's the difference between Vietnamese verbs
>>and Latin verbs;-)
> 
> 
> Say I buy into the indentation ideology. Python then has this inconsistency: :
> 
> Why do we need : at the end of our if and for loops? I spend approximately 6 
> minutes/100 lines of code going back and finding all of the times I missed :. 
> Is it for cheating?
 >
> if False: print ":"
> 
> Now, what happened to the whitespace idea here? This code seems very 
> unpythonic. I think : is great for slices and lamda where things go on one 
> line, but to require it to specify the start of a block of code seems a 
> little perlish.

During the usability studies for the language ABC, which Guido worked on 
before developing Python and also used indentation for grouping, it was 
found that the colon improved readability.

I don't know what those studies said about the frequency of people 
forgetting to put in the colon. Anecdotally, I can say that I do it very 
rarely.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter



More information about the Python-list mailing list