Non-Indented python

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Nov 27 07:31:44 EST 2001


Tue, 27 Nov 2001 01:27:15 +0000 (UTC), Huaiyu Zhu <huaiyu at laplace.almaden.ibm.com> pisze:

> - That there is no reason to associate tab with any equivalent in spaces.
>   It should only be used as a distinct character in its own right.

What should a Python interpreter do with this?

<TAB>if 0:
<TAB><TAB>print "0"
<SPACE><SPACE><SPACE><SPACE><SPACE><SPACE><SPACE><SPACE>print "1"

> There is no problem in using it the right way - as a place-holder of
> indentation level.

There is. When some lines use tabs and others use spaces, different
tab sizes may cause different interpretations.

But there is no problem with mixing tab and spaces if a tab *always*
moves to the next multiple of 8 columns. That's why especially in a
language with meaningful indentation it's important to have a consistent
tab size.

Mixing tabs and spaces is not recommended because some people use tabs
in a wrong way (with a size different than 8), but I would not forbid it.
One should not be forced to use tabs only because other lines in this
file use tabs.

Just keep a consistent tab size of 8 and problems disappear.

> For example, got a problem with mixing tab and space?  Well, just don't do
> it.  They are two different characters.  It's the same as mixing w with vv
> or mixing m with rn.

So should Python reject lines indented with spaces? If it should allow
either spaces or tabs (as currently), it's not like mixing w with vv.

> Why would it matter to you how other people are displaying a particular
> character on screen?

Because the semantics of a Python program depends on the physical
column when a line starts, after translation of tabs to spaces.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^
QRCZAK



More information about the Python-list mailing list