string split

Dave Harrison dlharris at mail.usyd.edu.au
Mon Dec 9 17:27:42 EST 2002


I think it would most likely be because you are not working the two as the one line

Make sure that you have it all on the one line then do the split function.  At the moment I think you are trying to split a list object.

ie.

str = ''
file = ('foofile').readlines()

for line in file:
	str = str + line

name = string.split(str, '\n')


	

lily (utakecare2 at yahoo.com):
> 
> Hello,
> 
>              I had a question with split function in strings:
> 
> My string is:
> 
> Requirement: O111
> |
> 
> 
> where I would like to split the string into a list of two tokens: 'Requirement: O111' and '|'
> 
> Hence my code is as follows:
> 
> name = string.split(nametrace,'\n')
> 
> But I get an exception saying 
> 
> 'TypeError: list objects are unhashable'
> 
> What is my mistake in the above code?
> 
> Thank you.
> 
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now




More information about the Python-list mailing list