Siah wrote:

> I need to convert the string: '(a, b, "c", d, "e")' into the
> following list ['a', 'b', 'c', 'd', 'e']. Much like a csv reader
> does. I usually use the split function, but this mini-monster
> wouldn't properly get split up due to those random quotations
> postgresql returns to me.

I heavily suggest you to look at the docs -- those are very basic
functions.

http://docs.python.org/lib/string-methods.html

One solution might be:

>>> results = []
>>> for part in '(a, b, "c", d, "e")'.split(","):
...  part = part.strip()
...  part = part.strip("(),\"")
...  part = part.strip()
...  results.append(part)
... 
>>> print results
['a', 'b', 'c', 'd', 'e']
>>> 

Regards,


Björn


-- 
BOFH excuse #285:

Telecommunications is upgrading. 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to