string split
Cliff Wells
LogiplexSoftware at earthlink.net
Mon Dec 9 17:22:03 EST 2002
On Mon, 2002-12-09 at 14:09, lily wrote:
> 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'
Works for me:
Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
[GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> nametrace = "Requirement: O111\n|"
>>> name = string.split(nametrace,'\n')
>>> name
['Requirement: O111', '|']
>>>
> What is my mistake in the above code?
Not posting enough of it ;)
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20021209/3399fc8b/attachment.sig>
More information about the Python-list
mailing list