Whitespace as syntax (was Re: Python Rocks!)

Paul Prescod paul at prescod.net
Mon Feb 7 20:10:29 EST 2000


fcahoon at my-deja.com 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).

Python code does not become mis-formatted for the same reason that curly
braces do not disappear in C.

If you leave out any significant characters in Python, the compiler
tells you that you have done so, just as a C ompiler would. In the
extremely rare case that this happens to production code you do exactly
what you would do in C if your curly braces all disappeared. You roll
back to the last version that compiled (or in the Python case, "ran").

> Python does address some of the shortcomings of
> Perl -- notably, it is far more maintainable in a multi-developer
> envirionment -- despite the flawed decision to use whitespace as 
> syntax.

There are literally *hundreds* of languages that are more maintainable
than Perl. If you want to understand why Python is becoming so popular
you will have to work much harder than that. In fact, you may even have
to try it.

> This fact, and a butterfly flapping its wings in the Amazon jungle, has
> led Python to achieve "critical mass".

Oh, I see. You _have_ thought deeply about this issue.

> Iff I _must_ live with Python, then I will be driven to my second tactic
> -- a comment-driven fix for the lack of adequate information in the the
> python source to restore mis-formatted code.  

There is a library in the Python distribution that reformats code
according to structure described in comments. It looks like your problem
is solved. Welcome aboard.

In the Python world, we do get a little bit tired of people coming in
and telling us how Python is unusable because of the whitespace
"problem". Most of us have built systems with many developers
distributed around the world on heterogenous systems of thousands of
lines and never had these "whitespace eating nanovirus" problems. If you
have a whitespace eating nanovirus in your computer (or company) be glad
that the Python compiler will help you find it and root it out before it
destroys one of your makefiles!

> First is the _hardcore_ promotion of realistic alternatives to Python.
> I believe that the Ruby language (http://www.ruby-lang.org/) has the OO
> advantages of Python without the whitespace-as-syntax deficiency. 

While you are promoting Ruby, also consider Corbascript, Pike, Lua,
Guile and Squeak. You'd better cover your bases!

-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for himself
"If I say something, yet it does not fill you with the immediate
burning desire to voluntarily show it to everyone you know, well then,
it's probably not all that important."
    - http://www.bespoke.org/viridian/




More information about the Python-list mailing list