Re: Converting a string to list for submission to easygui multenterb​ox

ksals kbsals5179 at gmail.com
Tue May 1 17:09:52 EDT 2012


On May 1, 4:26 pm, John Gordon <gor... at panix.com> wrote:
> In <316efebe-7f54-4054-96b1-51c7bb7b7... at f5g2000vbt.googlegroups.com> ksals <kbsals5... 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
> gor... at panix.com              B is for Basil, assaulted by bears
>                                 -- Edward Gorey, "The Gashlycrumb Tinies"
>>
The original choice looks like this when I print it:
print(choice)
('ksals', '', 'alsdkfj', '3', '')
I need to submit these as defaults to a multenterbox. Each entry above
ksals, "", "alsdkfj', 3 , '' need to fill the five fields in the box.
I tried your suggestion so you must be right it is a tuple of 5
strings. But I need them to work in an instruction like
fieldValues = eg.multenterbox(msg1,title, fieldNames, choice)
fieldNames has 5 fields.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /