Teaching Programming

D'Arcy J.M. Cain darcy at druid.net
Tue May 4 11:49:25 EDT 2010


On Wed, 5 May 2010 00:35:18 +1000
James Mills <prologic at shortcircuit.net.au> wrote:
> In my experience of non-indentation sensitive languages
> such as C-class (curly braces) it's just as hard to keep track
> of opening and closing braces.

Harder.  That was the big "Aha!" for me with Python.  My first
programming language was Fortran in 1969 so when I saw indentation as
syntax I also recoiled in horror for about 0.5 seconds.  However, I
immediately realized that from now on I could be sure that if it looked
right then it was right.

    for (x = 0; x++; x < 10);
        printf("Current number is %d\n", x);

Or...
    
    for (x = 0; x++; x < 10);
    {
        printf("Current number is %d\n", x);
    }

Oops.  Looks right but isn't.  Try to make that mistake in Python.

Note untested - I wasn't about to fire up an editor, create a C
program, add the includes, compile and run the a.out just to test
this.  Another way that Python excels.  However, I am pretty sure that
the above would compile.

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list