Some Python 2.1 ideas
tino at wildenhain.de
Sun Dec 24 05:16:01 EST 2000
Erno Kuusela wrote:
> >>>>> "Bob" == Bob Alexander <bobalex at home.com> writes:
> | ---- String method to remove trailing newline
> i think it would be prettier and more useful to have methods
> to remove a given prefix/suffix from the beginning or the end of a
> string. maybe add optional arguments for lstrip/rstrip, or
> introduce new methods rtrim/ltrim?
You mean removing it only if it matches?
If yes, you can at least use for ltrim:
if not, you can simply use <string>[len(begin_to_match):]
More information about the Python-list