On Apr 20, 2007, at 3:15 PM, [EMAIL PROTECTED] wrote:
> On Apr 20, 1:51 pm, kevinliu23 <[EMAIL PROTECTED]> wrote:
>> ['', 'b34bx5b', 'c4a5a6']
>>
>> My question is, why is the first element of projectOptions an empty
>> string? What can I do so that the first element is not an empty
>> string? but the 'b34bx5b' string as I expected?
>>
>> Thanks so much guys. :)
>
> The reason you have an empty string at the beginning is because you
> are "splitting" on a character that happens to include the first
> character in your string. So what you are telling Python to do is to
> split the beginning from itself, or to insert a blank so that it is
> split.

So why does this not happen when you use the empty split() function?

[EMAIL PROTECTED] /Users/tgrav --> python
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> a = " 456 556 556"
 >>> a.split()
['456', '556', '556']
 >>> a.split(" ")
['', '456', '556', '556']
 >>>

What exactly does .split() use to do the splitting?

Cheers
  Tommy
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to