title: Send command and a argument to python socket server
body: <p>Im currently setting up a <strong>server</strong> with the following while:</p>
  
  <pre><code>try:
      while 1:
          #wait to accept a connection - blocking call
          conn, addr = s.accept()
          print time.ctime() + ' Connection from: ' + addr[0] + ':' + str(addr[1])
          #start new thread takes 1st argument as a function name to be run, second is the tuple of arguments to the function.
          start_new_thread(shreddingclient ,(conn,))
  
  except KeyboardInterrupt:
      print "Exiting gracefully anyway"
  finally:
      s.close()
  </code></pre>
  
  <p>And i was thinking it would be nice too be able to send a command, and argument to the server, the <code>def shredding client</code>.</p>
  
  <p>I have googled, a lot, and have found something like this on the <strong>client side</strong>:</p>
  
  <pre><code>def send_data(self, com, arg):
         content={"command": com, "arg": arg}
         return json.dumps(content)
  </code></pre>
  
  <h1>My question:</h1>
  
  <p>How will <code>def shreddingclient</code> look like to accept commands, an argument to execute other <code>def</code>s?</p>
  
  <p>(This is to avoid that <code>shreddingclient</code> will be a huge <code>if</code>/<code>elif</code> function)</p>