Whitespace as syntax (was Re: Python Rocks!)

fcahoon at my-deja.com fcahoon at my-deja.com
Tue Feb 8 04:08:45 CET 2000


In article <024201bf71cb$bfc6a670$01646464 at computer>,
  "Neil Hodgson" <neilh at hare.net.au> wrote:
> > If python code were to become mis-formatted (and given my
> > experience, I have to believe that sooner or later this _will_
> > happen) there is _no way_ to be certain what the original
> > author's intent was, much less to fix it automatically.  This
> > is a Bad Thing(tm).
>
>    I'd like to understand what 'mis-formatting' you are worried about.
> Either Python code is syntactically valid or it is not. If the
original
> author has given you syntactically valid Python, then it has an
unambiguous
> structure and can be reformatted to use any spacing / tabbing approach
you
> wish to standardise on.
>
>    Neil

This is what I've seen in some C code that's been through many hands:

The old-timers used 8-space tabs to effect 3-space indentation.  Don't
ask me why.  The 2nd generation of coders set their tabs to 3 spaces in
the editor, editing some parts of the code, unaware that other parts of
the same file contained 8-space tabs.  Tabs were converted to spaces
under the mistaken assumption that they were all 3-space tabs.

For a hypothetical pseudo-python example, consider this:
(For clarity I will show the indentation using "<S>" for a space and
"<T>" for a tab)

if condition1:
<S><S><S><S>statement1
<S><S><S><S>statement2
<S><S><S><S>if condition2:
<S><S><S><S><S><S><S><S>statement3
<T>statement4

To which loop does statement4 belong?

f


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list