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 :
- It provides bloc delimiters (end of blocks) in the for of comments (like "#end if" or "#end for" etc ... )
- This allows one to check / restore the indentation of Python code, in cases where>
- A copy/paste went wrong
- The indentation of a Python source got corrupted when the script was posted on web page, send via email etc ...
- Standardise (fix) sources which happily mix whitespaces and tabs
- 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
Serge Hulne