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

Cameron Simpson cs at zip.com.au
Tue May 1 19:36:30 EDT 2012


The tutorial suggests multchoicebox returns an interable of chosen
items, in fact probably a seqeunce. So...

On 01May2012 14:50, ksals <kbsals5179 at gmail.com> wrote:
| This is a small excert to show you what I get
|
| for choice in easygui.multchoicebox(msg1, title,qstack):
|             if choice[0] == None:
|                 print ("No entries made")
|                 break

This is the wrong test. "choice" is 

|             print("CHOICE IS: ",choice)    .....         CHOICE IS:
| ('', 'ksals', '', '', '')

Does this really happen? This code associated with the for loop?

I'd expect easygui.multchoicebox to return a list (or tuple) and
"choice" to be a single string from the list. Did your print() call
happen after the quoted "for" loop or after a statement like this?

  choice = easygui.multchoicebox(msg1, title, qstack)

|             c=list(choice)
|             print("C IS: ",c)              .....      C IS:  ['(',
| "'", "'", ',', ' ', "'", 'k', 's', 'a', 'l', 's', "'", ',', ' ', "'",
| "'", ',', ' ', "'", "'", ',', ' ', "'", "'",
| ')']

Ok, that really does look like "choice" is a string. I'm really very
surprised.

What does this do?

  choices = easygui.multchoicebox(msg1, title, qstack)
  print("type(choices) =", type(choices))
  print("choices =", repr(choices))

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

If you lie to the compiler, it will get its revenge.    - Henry Spencer



More information about the Python-list mailing list