Re: [Tutor] tokenizing a simple string with split()

2007-03-31 Thread David Heiser
i Petre Cc: tutor@python.org Subject: Re: [Tutor] tokenizing a simple string with split() Andrei Petre wrote: > 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 >

Re: [Tutor] tokenizing a simple string with split()

2007-03-31 Thread Kent Johnson
Andrei Petre wrote: > 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() >

Re: [Tutor] tokenizing a simple string with split()

2007-03-31 Thread Rafael Garcia
I think by "multiple characters" they mean more than one character for ONE separator. I don't know how to specify multiple separators. You could try something like this: s = "spam;egg mail" list = [] for t in s.split(";"): for u in t.split(" "): list.append(u) which yields: list = ['

[Tutor] tokenizing a simple string with split()

2007-03-31 Thread Andrei Petre
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 c