[Python-Dev] chomp()?
Guido van Rossum
guido@digicool.com
Thu, 28 Dec 2000 10:04:23 -0500
Someone just posted a patch to implement s.chomp() as a string method:
http://sourceforge.net/patch/?func=detailpatch&patch_id=103029&group_id=5470
Pseudo code (for those not aware of the Perl function by that name):
def chomp(s):
if s[-2:] == '\r\n':
return s[:-2]
if s[-1:] == '\r' or s[-1:] == '\n':
return s[:-1]
return s
I.e. it removes a trailing \r\n, \r, or \n.
Any comments? Is this needed given that we have s.rstrip() already?
--Guido van Rossum (home page: http://www.python.org/~guido/)