Possible Duplicate:
Python: Split string with multiple delimiters
I have a program where I am parsing a file by each line and splitting it into two half. After that for each half I am parsing each word from the line and appending it in a list.
Here mfcList1 is a list of lines from a text file. I am parsing each word in the line that are either separated by a comma or by a space. But it isn't exactly working.
for lines in mfcList1:
lines = lines.lstrip()
if lines!='':
p.append(string.split(lines,','or " "))
mfcList2 = reduce(lambda x,y:x+y,p)
print mfcList2
When i am using string.split it is working with only those elements who end with a comma it is ignoring the or operator I am using with split method. I want to slice off each and everyword from the line. They either end with a comma or with a space.
for eg. 'enableEmergencySpare=1 useGlobalSparesForEmergency=1 useUnconfGoodForEmergency=1',
this line is being stored as a single list element where as I am trying to split them using split method..
Can anyone pls suggest what i can do instead of using or operator... thanks..