[issue39418] str.strip() should have a means of adding to the default behaviour

Natalie Amery report at bugs.python.org
Wed Jan 22 07:16:56 EST 2020


New submission from Natalie Amery <phqcjz at fyvzl.net>:

If I want to remove the default set of 'whitespace' characters plus something else from a string there's currently no way to cleanly specify that.  In addition there's no way to programatically acquire what characters are considered whitespace so you can't call split with an argument constructed of existing whitespace characters with the new things you need.

As an example you could have an additionally= parameter such that:

"   ( 123 )   ".strip() gives "( 123 )" and
"   ( 123 )   ".strip(additionally="()") gives "123"

I've not given that any thought so it's probably not the best way of solving the problem.

----------
messages: 360459
nosy: senji
priority: normal
severity: normal
status: open
title: str.strip() should have a means of adding to the default behaviour
type: enhancement
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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


More information about the Python-bugs-list mailing list