Non-Indented python

Jeff Shannon jeff at ccvcorp.com
Wed Nov 28 14:27:32 EST 2001


Huaiyu Zhu wrote:

> Question: What should tab be default to in terms of other charactors, or
>   screen positions, or editor actions, or anything else that is not the tab
>   charactor?
>
> Answer: It shouldn't.

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...

Tab characters are useless if they cannot be represented on the screen.  Standard
usage since the dawn of typewriters has been that tab is roughly equivalent to
spaces.  Sure, you can define Tab to be its own thing, and this will clear up some
confusion perhaps, but how are you going to display them?  How are you going to
indicate their existence?  If you use a method that is visually distinct from
spaces, then you're going to confuse and irritate everyone who has consistently
used tabs and spaces as equivalent (in coding, tabulation, prose, etc...)   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.

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.

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.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list