Actually these are "fake" bloc delimiters (in the shape of comments, see example in the original post).
By this I mean they are used by the formatting tool (pindent) only, not by the language (Python itself).
They are (generated by and used by) pindent for the sake of being able to fix the indent level in python code when :
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 :Basically the idea is the same as the Go language "gofmt" (Go format).
- 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 ...)
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