[Tutor] perl's chomp equivalent?

Daniel Yoo dyoo@hkn.EECS.Berkeley.EDU
Mon, 17 Jul 2000 14:22:52 -0700 (PDT)

On Mon, 17 Jul 2000, Tim Condit wrote:

> Is there anything similar to perl's chomp, which removes newline
> characters from the end of a line? I'm using this, which works just fine
> if not..

string.strip() will chomp off newlines.  Here's what the built-in
documentation says about it:

>>> from string import strip
>>> print strip.__doc__
strip(s) -> string

Return a copy of the string s with leading and trailing
whitespace removed.

So it does a little bit more than chomp --- it goes at it from both ends.