Structure using whitespace vs logical whitespace

cmdrrickhunter@yaho.com conrad.ammon at gmail.com
Mon Dec 15 15:27:12 EST 2008


On Dec 15, 11:10 am, Terry Reedy <tjre... at udel.edu> wrote:
> > In general, I'm using indentation to show logical flow through code.
>
> That, of course, is what Python does.
>
Python does NOT use indentation to show logical flow.  It uses it to
show syntactical flow.  The XML writer is the perfect example of a
case where they are different.  In most cases, syntactic flow is close
enough to logical flow.  There are a few cases where you can 'draw a
picture' of the algorithm in code if you are whitespace insensitive.

I've not used the "with" keyword before, and it does seem to handle
this troublesome case quite well.  I learned python before it was
around, and never really studied it hard enough.  I'll have to
investigate what other tricks can be done with it.

I'm a big fan of the rule "make the 90% easy and the remaining 10%
possible."  Whitespace sensitivity makes the 90% easy, and just from
the looks of it, the 'with' command and whitespace insensitive
expressions give the remaining 10%.  And I do like the automated
support for "finally" clauses when using 'with'

Thanks for the help, everyone!



More information about the Python-list mailing list