On Thu, May 26, 2011 at 00:29, Serge Hulne <serge.hulne@gmail.com> wrote:
Suggestion: Integrate the script "pindent.py" as standard command for formatting pyhton code

Here is the link;
http://svn.python.org/projects/python/trunk/Tools/scripts/pindent.py

Pindent stands for "Pyton indent":

Goal :
  1. It provides bloc delimiters (end of blocks) in the for of comments (like "#end if" or "#end for" etc ... )
  2. This allows one to check / restore the indentation of Python code, in cases where>
    1. A copy/paste went wrong
    2. The indentation of a Python source got corrupted when the script was posted on web page, send via email etc ...
    3. Standardise (fix) sources which happily mix whitespaces and tabs
    4. Make Python code more readable for developers used to end of blocs delimiters (Ruby, C, C++, C#,Java, etc ...)
 Basically the idea is the same as the Go language "gofmt" (Go format).

Example:

#-------------------
- Before using pindent:

#!/usr/bin env python

i = 0
for c in "hello world":
    if c == 'l':
        i+=1
        print "number of occurrences of `l` :", i

#------------------
- After using indent:

#!/usr/bin env python

i = 0
for c in "hello world":
    if c == 'l':
        i+=1
        print "number of occurrences of `l` :", i
    # end if
# end for

This is already included in the Python source tree, so I'm not sure what further inclusion/integration you are suggesting. I don't find this style necessary nor is it really a good style to promote, especially because Python isn't Ruby, C++, or any of the languages you listed.

The only time I've found it sort-of ok to do this is if a block nested in other blocks spans more than the height of one monitor view, which isn't often. Even then, most IDEs and editors handle this by having optional guides for block beginning and ending.