From: John G. <jgo...@co...> - 2004-04-26 20:01:25
|
On Mon, Apr 26, 2004 at 12:52:08PM -0700, Blair Zajac wrote: > > > lstrip and rstrip are useful in some cases. For instance, if you wish > > > to remove trailing whitespace such as \n but preserve leading whitespace > > > (perhaps it's indentation that you wish to keep), rstrip is useful. > > > > what about : strip ~chars:"\n" then ? > > Maybe to be consistent with Perl's function, name it chomp? > > chomp This safer version of "chop" removes any trailing string that > corresponds to the current value of $/ (also known as > $INPUT_RECORD_SEPARATOR in the "English" module). It returns > the total number of characters removed from all its arguments. > It's often used to remove the newline from the end of an input > record when you're worried that the final record may be missing > its newline. When in paragraph mode ("$/ = """), it removes strip/rstrip/lstrip are consistent with Python... so I guess you get to choose one :-) |