[Python-bugs-list] [ python-Bugs-811604 ] "string".split behaviour for empty strings

SourceForge.net noreply at sourceforge.net
Wed Sep 24 04:51:28 EDT 2003


Bugs item #811604, was opened at 2003-09-24 13:50
Message generated for change (Comment added) made by meyarivan
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=811604&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: T.Meyarivan (meyarivan)
Assigned to: Nobody/Anonymous (nobody)
Summary: "string".split behaviour for empty strings

Initial Comment:


"".split() -> []



"".split(' ') -> ['']



It is not clear from the documentation as to what is

the defined behaviour in the above case. To say the

least, it is 

completely counter-intuitive..(splitting an empty

string should

return the list [''] in both cases).



>From stringobject.c, the behaviour of split_whitespace

(i.e split called without sep) and string_split (split

called with sep) is different for empty

strings..perhaps the function split_whitespace needs to

be patched.

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

>Comment By: T.Meyarivan (meyarivan)
Date: 2003-09-24 14:21

Message:
Logged In: YES 
user_id=30470

"".split(None) -> [] 



which is expected because in the case when no sep is

specified and when sep == None, split_whitespace is called..

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

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



More information about the Python-bugs-list mailing list