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

casevh at comcast.net casevh at comcast.net
Sat Mar 26 00:03:34 EST 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: :

It is just as inconsistent as putting a colon after inconsistency in
the above line.

I've always viewed it as analogous to english grammar -

Go to the store and buy the following:
    Milk
    Eggs
    Spam

    If there is a sale on beer:
        Buy Heineken
    otherwise:
        Buy Budweiser

The colon terminates the directive and then the objects are indented.

>
> 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.
>
> --
> James Stroud, Ph.D.
> UCLA-DOE Institute for Genomics and Proteomics
> Box 951570
> Los Angeles, CA 90095
> 
> http://www.jamesstroud.com/




More information about the Python-list mailing list