jerryolive 0 Newbie Poster

The below code works, but the default value for the test method will be None.

I'm trying to figure out how to read input from the user, convert that into a list (or whatever), and then based on the number of arguments the user inputs, it will be sent into the function.

The function could change, so I'm stuck with a problem.

class ConsolePop3Client(SimplePop3Client):
  prompt="$> "
  args_prompt="-->"
  commands=None

  def __init__(self,host,port=110,timeout=None):
    SimplePop3Client.__init__(self,host,port,timeout) 
    self.commands=\
      {
        "test" : self.test
      }

  def test(self,x=None):
    print x


  def run(self):
    command=""
    while (command != "exit"):
      command=raw_input(self.prompt)
#howto get args into func where len(args) may change, and func may also change.
      self.commands[command]()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.