how to convert string to list or tuple

Fuzzyman fuzzyman at gmail.com
Wed Jun 1 09:42:59 EDT 2005


flyaflya wrote:
> a = "(1,2,3)"
> I want convert a to tuple:(1,2,3),but tuple(a) return ('(', '1', ',',
> '2', ',', '3', ')') not (1,2,3)

Probably a bit late... but there's always listquote - It's part of the
pythonutils module.

http://www.voidspace.org.uk/python/pythonutils.html

It will turn strings to lists, including nested lists.

Best Regards,

Fuzzy
http://www.voidspace.org.uk/python




More information about the Python-list mailing list