Why not enforce four space indentations in version 3.x?

Miles Kaufmann milesck at umich.edu
Wed Jul 15 14:24:23 EDT 2009


On Jul 14, 2009, at 5:06 PM, David Bolen wrote:
> Are you sure?  It seems to restrict them in the same block, but not in
> the entire file.  At least I was able to use both space and tab
> indented blocks in the same file with Python 3.0 and 3.1.

It seems to me that, within an indented block, Python 3.1 requires  
that you are consistent in your use of indentation characters *for  
that indentation level*.  For example, the following code seems to be  
allowed:

def foo():
<TAB>if True:
<TAB><SP><SP>x = 1
<TAB>else:
<TAB><TAB>x = 2
<TAB>return x

But replacing any of the first tabs on each line with 8 spaces  
(without replacing them all), which previously would have been  
allowed, is now an error.

-Miles




More information about the Python-list mailing list