Seeking assistance - string processing.

John Machin sjmachin at
Tue Nov 14 12:55:09 CET 2006

John Machin wrote:

>    new = line[:-1] + "===\n"

To allow for cases where the last line in the file is not terminated
[can happen],
this should be:

    new = line.rstrip("\n") + "===\n"
    # assuming you want to fix the unterminated problem.


More information about the Python-list mailing list