A modest indentation proposal

Neil Schemenauer nas at python.ca
Fri Nov 30 12:41:00 EST 2001


Erann Gat wrote:
> Skip:
> > In Python, if it looks right, it is right.
> 
> No, that's not true.  Consider the following two alternative code fragments:
> 
> if x:
>   foo()
> baz()
> 
> if x:
>   foo()
>   baz()
> 
> They both look right, but they can't both be right.

How do they both look right?  In the first case baz() is always called.
In the second case it's called if x is true.  A larger indent (say 4
spaces) would make things even more clear.

As for moving code around, I agree that it would be nice if the block
structure of the code was preserved.  I think the solution for this
problem is not to add extra syntax to the language but to have smarter
editors.  I believe effbot and the other people at Python Labs are
working on a "refactoring browser" for Python.  It would be similar to
what has been done for Smalltalk.

  Neil




More information about the Python-list mailing list