how to "normalize" indentation sources

John Salerno johnjsal at NOSPAMgmail.com
Thu May 25 12:38:48 EDT 2006


Tim Peters wrote:
> [John Machin, quoting reindent.py docs]
>>> remove empty lines at the end of files.  Also ensure the last line ends
>>> with a newline.
> 
> [John Salerno]
>> don't those two things conflict with one another?
> 
> No.  This is the repr of a file with (3) empty lines at the end:
> 
>    "a file\n\n \n  \t    \n"
> reindent.py changes that to:
> 
>    "a file\n"
> 
> This is the repr of a file with no newline at the end:
> 
>    "a file"
> 
> reindent.py changes that to:
> 
>    "a file\n"
> 
>> or is the newline added after empty lines are removed?
> 
> False dichotomy ;-)

So the line below the last line of the file isn't actually considered an 
empty line, even though you can move the cursor to it in a text editor?

If you have a file that has one line and it ends with a newline, at 
least in my text editor the cursor then moves down to the next line, but 
is this just a detail of the way the editor itself works, and nothing to 
do with the file? (i.e., there is really only one line in the file, not 
two?)



More information about the Python-list mailing list