Converting a string to list for submission to easygui multenterbox
John Gordon
gordon at panix.com
Tue May 1 16:26:53 EDT 2012
In <316efebe-7f54-4054-96b1-51c7bb7b7b25 at f5g2000vbt.googlegroups.com> ksals <kbsals5179 at gmail.com> writes:
> Please help a newbe. I have a string returned from an esygui
> multchoicebox that looks like
> this: ('ksals', '', 'alsdkfj', '3', '') I need to convert this to
> this: ['ksals', '', 'alsdkfj', '3', '']
That looks like a tuple which contains five strings. But you said it's
a string, so I'll believe you.
>>> x = "('ksals', '', 'alsdkfj', '3', '')"
>>> print x
('ksals', '', 'alsdkfj', '3', '')
>>> y = "[%s]" % x[1:-1]
>>> print y
['ksals', '', 'alsdkfj', '3', '']
--
John Gordon A is for Amy, who fell down the stairs
gordon at panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
More information about the Python-list
mailing list