[Tutor] tokenizing a simple string with split()

Andrei Petre andrei.petre at gmail.com
Sat Mar 31 23:43:16 CEST 2007


I want to split a string like "C:\My\Doc\;D:\backup\" with two separators: \
and ;
I found that \ is handled with *raw string* notation r"". But the problem i
encountered is with split() function.
In the 2.5 reference is said that "The sep argument of the split() function
may consist of multiple characters". But I cannot figured out why this
simple example not working:

s = "spam;egg mail"
s.split("; ")

output: ['spam;egg mail']

instead of ['spam', 'egg', 'mail']

any suggestion is welcome,
andrei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070401/1004ee19/attachment.html 


More information about the Tutor mailing list