Whitespace as syntax (was Re: Python Rocks!)

François Pinard pinard at iro.umontreal.ca
Mon Feb 7 20:21:17 EST 2000


fcahoon at my-deja.com writes:

> Different tab conventions have been used in different places in the
> codebase, and sometimes tabs have been converted to spaces incorrectly
> as well -- leaving a horrible mess.  Fortunately it is easy to fix this
> with a pretty-printing program (I use "M-x indent-region" in emacs).
> That is because the information required to fix the indentation _is
> present in the file_.

Best might be to consider that TABs should just plain not be used when
writing Python.  Python could even be modified to consider that a mix of
spaces and TABs is a syntactical error.  Should allow TABs only, however,
for people limiting themselves to this use.  In my opinion, that would
quickly eradicate the problem at the source: people mixing TABs and spaces
would be warned immediately, and we would soon stop discussing the matter.

In the meantime, fix your editor and tools so they do not generate TABs.
It might be as simple as that, you know! :-)  No mess, no problem.

> So now I'm getting scared that Python will become _status quo_ and
> we will soon all have to live with the consequences of this perilous
> design decision.

The design decision is good, and in my case, very much welcome.  Editors may
be lacking.  Use good editors, and configure them appropriately.  You will
be giving yourself a treat anyway by doing so! :-)

> For this I suggest the comments #{ and #} because they are concise,
> look like C/Java/Perl, and can be put on the same line as the first/last
> statements (obviating the "it takes an extra line" objection I have read
> elsewhere in this thread).

You could surely do that, for the time it would take to tame yourself that
they are good, safe ways to never have problems.  Once there, these extra >
comments could easily be removed :-).

> While I'm sure this will strike many of you as a bunch of gratuitous
> flamage, I really am only trying to promote reasoned discussion, honest.

Of course.  You are very welcome.  Problems sometimes go from monstrous
to innocuous, when we take the time to spell them out, and share about them.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard






More information about the Python-list mailing list