[ python-Bugs-1171994 ] error in documentation for splitting empty string

SourceForge.net noreply at sourceforge.net
Wed Mar 30 19:56:53 CEST 2005


Bugs item #1171994, was opened at 2005-03-28 12:49
Message generated for change (Comment added) made by tjreedy
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1171994&group_id=5470

Category: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Wai Yip Tung (tungwaiyip)
Assigned to: Nobody/Anonymous (nobody)
Summary: error in documentation for splitting empty string 

Initial Comment:
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()
[]


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

Comment By: Terry J. Reedy (tjreedy)
Date: 2005-03-30 12:56

Message:
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.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1171994&group_id=5470


More information about the Python-bugs-list mailing list