What is the Python equivalent of Perl\'s chomp function, which removes the last character of a string if it is a newline?
chomp
I don't program in Python, but I came across an FAQ at python.org advocating S.rstrip("\r\n") for python 2.2 or later.