[New-bugs-announce] [issue39607] Add a parameter to strip, lstrip, and rstrip that treats the first parameter as a full string

Chris Rogers report at bugs.python.org
Tue Feb 11 04:40:20 EST 2020


New submission from Chris Rogers <chihuahuasare2cute at gmail.com>:

Consider this string:

'mailto:mailto:mailto:main at example.com'

If you try to remove the mailtos with lstrip('mailto:'), you'll be left with this:

'n at example.com'

That's because the three strip functions look at each character separately rather than as a whole string.

Currently, as a workaround, you have to either use regex or a loop. This can take several lines of code.

It would be great if the strip functions had a second parameter that lets you keep the first parameter intact.

You could then use this code to get the desired result:

'mailto:mailto:mailto:main at example.com'.lstrip('mailto:', true)
>>main at example.com

----------
messages: 361791
nosy: Chris Rogers
priority: normal
severity: normal
status: open
title: Add a parameter to strip, lstrip, and rstrip that treats the first parameter as a full string
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39607>
_______________________________________


More information about the New-bugs-announce mailing list