[issue2809] string docstring doesn't mention that ' '.split() != ' '.split(' ')

David Fraser report at bugs.python.org
Sun May 11 20:24:56 CEST 2008


David Fraser <davidf at sjsoft.com> added the comment:

I don't think this really addresses the issue properly...

The original docstring read:
+Note that not specifying sep (or using None) will cause\n\
+empty strings to be removed from the output. thus ' '.strip()\n\
+returns []. while ' '.strip(' ') returns ['', ''].
(Obviously strip is wrong here, it should be split)

The committed docstring reads:
+If sep is not specified or is None, any whitespace string is a
separator and leading and trailing whitespace is stripped before splitting.

But the point is not just that leading and trailing whitespace is
stripped; ''.strip() returns [] while ''.strip(' ') returns ['']. This
is probably the most unexpected corner case; it seems to be better to
say that empty strings are removed from the output.

----------
nosy: +davidfraser

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2809>
__________________________________


More information about the Python-bugs-list mailing list