Indentation/whitespace

Larry Bates larry.bates at websafe.com
Fri Dec 23 13:22:59 EST 2005


Joe wrote:
> Is Python going to support s syntax the does not use it's infamous
> whitespace rules? I recall reading that Python might include such a
> feature. Or, maybe just a brace-to-indentation preprocessor would be
> sufficient.
> 
> Many people think Python's syntax makes sense. There are strong
> feelings both ways. It must depend on a person's way of thinking,
> because I find it very confusing, even after using with Python for some
> time, and trying to believe the advice that I would learn to like it.
> The most annoying thing is that multiple dedents are very unreadable. I
> still don't understand how anybody can think significant-but-invisible
> dedentation is a good thing.
> 
> Note: No need to follow up with long opinions of why indentation is
> good -- they have been posted hundreds of times. It just seems that
> Python developers think the whitespace thing is only an issue for
> newbies. I think that many experienced users don't learn to like it,
> but instead just learn to live with it.
> 
Characterizing indentation as "invisible" isn't really fair.
It it WAY more visible than a { character. IMHO the
indentation works very well.  I've tried to wade through PHP,
JavaScript, C code that uses those <expletive deleted>
brace ({}) blocks until my head hurt, especially if they
didn't indent as well as using the braces.  If they indent
so I can actually read the code, why also use braces to
clutter things up?  I've solved the multiple dedent problem
by inserting a comment that shows where the indented blocks
end (sort of where the ending brace (}) would have been.
I also find that if I'm indenting more than a couple of
levels, I probably need to refactor my code into smaller
objects or rethink the process so that I process collections
of objects.  I've written in many different languages over
a span of 32+ years and it seems to work for me.

-Larry



More information about the Python-list mailing list