Whitespace as syntax (was Re: Python Rocks!)
Dennis E. Hamilton
infonuovo at email.com
Tue Feb 8 15:52:00 CET 2000
My way of dealing with this, before Python too, is to use an editor where I
can specify that tabs be replaced by the number of spaces required to
implement the current tab setting.
I haven't found any other way to avoid those illusions, and it provides the
satisfaction that someone else (as well as python) will see it exactly the
same way, no matter what their tab settings.
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of fcahoon at my-deja.com
Sent: Monday, February 07, 2000 22:16
To: python-list at python.org
Subject: Re: Whitespace as syntax (was Re: Python Rocks!)
In article <1262139803-5814898 at hypernet.com>,
gmcm at hypernet.com wrote:
> fcahoon at my-deja.com writes:
> [skip to example]
> > 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?
> Unambiguous. It belongs to "if condition2". Python interprets
> tabs as 8.
I think this should be in the Python FAQ. Or is it, and I missed it
somehow? If so, please excuse my oversight.
Suppose that I'm one of those set-tabs-to-logical-indentation sorts of
guys, so I set my tab width to 4, then look at this code in my editor.
Gee, it sure _looks_ like statement4 belongs to "if condition1"! And,
if I convert tabs to spaces when I save, statement4 _will_ belong to "if
condtion1". I've just unwittingly changed the logic of the code!
You may, of course, argue that this is unlikely, but it is still
plausible enough to make me _very_ nervous.
> [ ... rest snipped ... ]
More information about the Python-list