This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: error in documentation for splitting empty string
Type: Stage:
Components: Documentation Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, terry.reedy, tungwaiyip
Priority: normal Keywords:

Created on 2005-03-28 17:49 by tungwaiyip, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg24811 - (view) Author: Wai Yip Tung (tungwaiyip) Date: 2005-03-28 17:49
Below is extracted from http://www.python.org/doc/2.4/
lib/string-methods.html describing the string method 
split().

-----------------------------------------------------------------------
split([sep [,maxsplit]])

    ... Splitting an empty string with a specified separator 
returns an empty list.

    If sep is not specified or is None, a different splitting 
algorithm is applied. ... Splitting an empty string returns 
"['']".

-----------------------------------------------------------------------

The rationale for different treatment of splitting an empty 
string seems to be discussed in 811604. However the 
documentation seems to be the opposite of actual result.

>>> ''.split(',')
['']
>>> ''.split()
[]
msg24812 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2005-03-30 17:56
Logged In: YES 
user_id=593130

The new 2.4.1 doc (released today) at
http://docs.python.org/lib/string-methods.html
remains the same.

Verified behavior on 2.2.  If unchanged (lest code be broken), 
there does seem to be a problem.
msg24813 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2005-06-08 21:48
Logged In: YES 
user_id=11375

Fixed by rhettinger's commit in rev. 1.177.  Thanks for
reporting this!
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41769
2005-03-28 17:49:40tungwaiyipcreate