Some Python 2.1 ideas
Bjorn Pettersen
pbjorn at uswest.net
Mon Dec 25 14:12:41 EST 2000
Roy Smith wrote:
> "Bob Alexander" <bobalex at home.com> wrote:
> > Finally, I'd be disappointed if the name "chomp" actually survived! I
> > just used it in my initial post as a placeholder until a better name
> > came along, since some folks would likely recall it from Perl.
>
> We've already got the string methods strip, lstrip, and rstrip. Why not
> just add an optional second argument which is the class of characters to
> strip. Then chomp just becomes string.rstrip (input_string, '\n').
Even better, add two arguments similar to string split (character class,
number of occurrences).
"foo\n\n".rstrip('\n',1) -> "foo\n"
I think this is a good idea by itself and should be implemented for all of
strip, lstrip, and rstrip, however it doesn't solve the problem we want to
solve with chomp (removing a line terminator, whatever the line terminator
happens to be).
-- bjorn
More information about the Python-list
mailing list