[issue13391] string.strip Does Not Remove Zero-Width-Space (ZWSP)
Ezio Melotti
report at bugs.python.org
Tue Nov 15 16:24:26 CET 2011
Ezio Melotti <ezio.melotti at gmail.com> added the comment:
> So I guess this brings me back to my original issue. I'm not looking
> for particularly advanced stripping. I just want to remove all
> whitespace and other non-printing characters.
.strip only strips whitespace. Stripping non-printing characters and additional 'whitespace' is something that is too specific for a builtin method, especially because people might disagree on the characters that are considered whitespace and non-printing.
> Thus strip and isspace are now unusable methods in Python for common
> use cases. This seems unfortunate.
I believe they work fine for the common case -- in fact these methods have been around for years and no one complained.
Also Unicode has a number of more or less space-like characters that are not whitespace and whitespace chars that don't look like whitespace.
If one needs to strip a different set of (whitespace) chars, it's always possible to pass it to .strip or to define a new function like
def mystrip(s):
return s.strip().strip(u'\u200B\ufeff')
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13391>
_______________________________________
More information about the Python-bugs-list
mailing list