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

Bill Mill bill.mill at gmail.com
Fri Mar 25 14:47:11 EST 2005


On Fri, 25 Mar 2005 11:38:37 -0800, Robert Kern <rkern at ucsd.edu> wrote:
> 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.
> 

I can't remember having ever done it, although I am sure I have. The
real question is, though, 6 minutes per 100 lines of code? There
probably aren't more than 30 lines out of those 100 that should end in
a colon. Assuming you forget half your colons, you're spending upwards
of 20 seconds per colon?

If you want, I'll write a script that checks for colons at the end of
lines before increased indentation, and asks you if you want to put
one there - I could save you 5.8 minutes per 100 lines of code. How's
that for a productivity boost?

Peace
Bill Mill
bill.mill at gmail.com



More information about the Python-list mailing list