Issue2809
Created on 2008-05-10 15:48 by Neil Muller, last changed 2008-05-12 08:18 by davidfraser.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
split_docstring.diff
|
Neil Muller,
2008-05-10 15:48
|
Update docstring for split in stringobject and unicodeobject to note behaviour of split() vs split(' ') |
|
|
| msg66536 (view) |
Author: Neil Muller (Neil Muller) |
Date: 2008-05-10 15:48 |
|
split with no sep specified will not return an empty string, whereas
split with sep specified will.
The attached patch updates the docstring to reflect this for str.split
and unicode.split.
|
| msg66616 (view) |
Author: Georg Brandl (georg.brandl) |
Date: 2008-05-11 09:11 |
|
Committed a different (shorter) docstring change to the same effect as
r63050.
|
| msg66647 (view) |
Author: David Fraser (davidfraser) |
Date: 2008-05-11 18:24 |
|
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.
|
| msg66668 (view) |
Author: Georg Brandl (georg.brandl) |
Date: 2008-05-11 20:54 |
|
Okay, r63092 should satisfy you then. :)
|
| msg66714 (view) |
Author: David Fraser (davidfraser) |
Date: 2008-05-12 08:18 |
|
Yes that's fantastic, thanks :-)
|
|
| Date |
User |
Action |
Args |
| 2008-05-12 08:18:07 | davidfraser | set | messages:
+ msg66714 |
| 2008-05-11 20:54:27 | georg.brandl | set | messages:
+ msg66668 |
| 2008-05-11 18:24:55 | davidfraser | set | nosy:
+ davidfraser messages:
+ msg66647 |
| 2008-05-11 09:11:47 | georg.brandl | set | status: open -> closed resolution: fixed messages:
+ msg66616 |
| 2008-05-10 15:48:53 | Neil Muller | set | assignee: georg.brandl nosy:
+ georg.brandl components:
+ Documentation versions:
+ Python 2.6 |
| 2008-05-10 15:48:13 | Neil Muller | create | |
|