Let's make Python really strict about indentation
Alexis Layton
alexis.layton at post.harvard.edu
Sat Dec 1 01:53:35 EST 2001
I'm starting to believe the only solution to the indentation "mixups"
that occur
is to have Python become really strict about indentation, yet still
allow a mixture
of spaces and tabs.
This can be accomplished by defining SPACES and TABS as being
indentation characters
that have NO relation to one another. In this model, if someone is
crazy enough to
include a mixture of spaces and tabs as indentation, the rule is quite
simple: you can
only change the right side. A sequence of
TTSTS
for example, can be indented by adding more Ts and Ss, and can be
exdented by
removing the exact righmost sequence of Ss and Ts that occurred
previously. Anything
else would be an indentation error.
This does mean that the lexer has to keep knowledge of the currently
running indentation
string along with the "level", but "level" becomes merely an index into
the indentation prefix
string.
Of course, we could always become REALLY, REALLY strict and never allow
a mixture.
Alexis Layton
More information about the Python-list
mailing list