string.split bug?

Hameed Khan hameedkhaan at
Wed Feb 25 09:03:01 CET 2004

  i am not a python expert i am just a beginner and i
am taking part in thi discussion because i have
encounter the same problem just a week ago. and from
my experiments on different types of strings i have
concluded that python returns and extra empty string
as a last item when we provided delimeter to split()
function. and when we dont provide delimeter to
split() it checks the common delimeter (i think it
only looks for newline and whitespace delimeters) in
string and then splits the string according to that
delimeter and didn't return any extra empty string as
a last item in the list it returns.


Message: 5
Date: 24 Feb 2004 23:08:06 -0800
From: jcb at (MetalOne)
Subject: string.split bug?
To: python-list at
<92c59a2c.0402242308.35f55d4a at>
Content-Type: text/plain; charset=ISO-8859-1

string.split("") ==> []
string.split("",",") ==> ['']

I did not expect these to have different outputs.

I have a string with comma delimited numbers.
There can be zero or more numbers in the string
s = "0x41, 0x42"

I wanted to do
numbers = map(lambda x: int(x,16),

However, when there are no numbers, this generates an


Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

More information about the Python-list mailing list