Seeking assistance - string processing.

John Machin sjmachin at lexicon.net
Tue Nov 14 06:55:09 EST 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.

Cheers,
John




More information about the Python-list mailing list