Non-Indented python

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Thu Nov 29 14:13:55 EST 2001


On Wed, 28 Nov 2001 11:27:32 -0800, Jeff Shannon <jeff at ccvcorp.com> wrote:
>
>So, then... how is someone to know whether there is a tab character in the file
>they are editing, if there is no standard way to represent that character?  It
>seems to me that just about every *other* ascii character has *some* default action
>or symbol associated with it...

The idea is that for everyone there is a standard way to display tab, but it
may be different for each person.  Since code is exchanged via ascii
encoding instead of screen shots, different display does not matter.

> If you
>use a method that is visually equivalent to spaces, but can be customized to
>however many spaces the current user wishes... well, then you've got our current
>mess, with people wanting to mix the two and getting unpredictable results.

If you do not let Python interpret tab as equivalent to n spaces for
indentation, it remains predictable, because they can't be mixed.

>The only real solution to the problem, is to insist that using one or the other is
>an error.  Of course, many people will, without thinking, use spaces to indent even
>when they "know" that they should use tabs.  (As evidence, the Python docs specify
>that a tab is equal to two standard indent levels, and yet people insist on
>ignoring this specification...)  Tab keys, on the other hand, are easy (and
>relatively painless) to reinterpret to insert spaces.

The tab=2*indent spec does not work because it mandates the mixing of tab
and space if you want to use tab at all. 

>Therefore, the easiest, least painful solution, is to disallow tab characters for
>indenting.  I'd be happy to see *every* appearance of 0x09 for indenting become a
>syntax error.  This would require a fair amount of fixing old code, but not too
>much--running TabNanny once over all old code.  From that point on, there would be
>*no* confusion, as any reasonable editor would auto-convert tabs to spaces, and tab
>characters would disappear from code.

So the ideal world is all spaces, no tabs.  It is then not a big leap to
allow tab as a shorthand to replace the number of spaces used as indent.

Huaiyu



More information about the Python-list mailing list