sub-shell errors

Discussion in 'Python' started by Bigbowser, Aug 20, 2004.

  1. Bigbowser

    Bigbowser Guest

    Hi all,

    I'm trying to create a sub shell environment ( i
    haven't really got a reason, its more of a test,
    although hopefully it will make life easier ;P )
    but whenever i try to call the commands i've created
    i get :
    [ ice being the sub-shells name ]

    ICE> help
    Traceback (most recent call last):
    File "./console.py", line 27, in ?
    for cmd, callback in cmds:
    ValueError: too many values to unpack

    the code that is supposed to parse out the commands :
    ( all the commands are in a seperate file called
    commands.py, just for ease of maintance and
    readability )
    ---begin----
    import commands

    userInput = str()

    while(1):

    userInput == raw_input('ICE> ')
    cmds = { 'help' : commands.displayHelp, 'version' :
    commands.displayVersion,
    'authors' : commands.displayAuthors, 'exit' :
    commands.exitIce}

    for cmd, callback in cmds:
    if userInput == cmd:
    callback()

    -----end------

    I've tried several methods of going around this error,
    but none seem to work, the only other way i could do
    it is with a big series of if and elif statments ..
    but i don't reall want to for maintanance reasons ..
    :p

    if i print cmds ( the array that holds the commands )
    :

    {'version': <function displayVersion at 0x403db17c>,
    'exit': <function exitIce at 0x403dbc6c>, 'help':
    <function displayHelp at 0x403d6f44>, 'authors':
    <function displayAuthors at 0x403dbc34>}


    Thanks
    Bigbowser



    __________________________________
    Do you Yahoo!?
    Yahoo! Mail Address AutoComplete - You start. We finish.
    http://promotions.yahoo.com/new_mail
     
    Bigbowser, Aug 20, 2004
    #1
    1. Advertising

  2. Bigbowser wrote:
    > while(1):
    >
    > userInput == raw_input('ICE> ')
    > cmds = { 'help' : commands.displayHelp, 'version' :
    > commands.displayVersion,
    > 'authors' : commands.displayAuthors, 'exit' :
    > commands.exitIce}
    >
    > for cmd, callback in cmds:
    > if userInput == cmd:
    > callback()


    You mean

    for cmd, callback in cmds.items()

    ?

    Or much shorter:

    cmds[cmd]()

    Mathias
     
    Mathias Waack, Aug 20, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    1
    Views:
    412
    Steve C. Orr, MCSD
    Aug 19, 2003
  2. Kathy Burke
    Replies:
    3
    Views:
    417
    Kathy Burke
    Nov 24, 2003
  3. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,031
    Mark Goldin
    Jan 17, 2004
  4. Ben
    Replies:
    2
    Views:
    955
  5. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,170
    Lawrence D'Oliveiro
    May 20, 2011
Loading...

Share This Page