title: How to run different python functions from command line
body: <p>I'm trying to run different functions from a python script(some with arguments and some without)</p>
  
  <p>So far I have </p>
  
  <pre><code>def math(x):
     ans = 2*x
     print(ans)
  
  def function1():
    print("hello")
  
  if __name__ == '__main__':   
       globals()[sys.argv[1]]()
  </code></pre>
  
  <p>and in the command line if I type <code>python scriptName.py math(2)</code></p>
  
  <p>I get the error </p>
  
  <pre><code>File "scriptName.py", line 28, in &lt;module&gt;
  
  globals()[sys.argv[1]]()
  
  KeyError: 'mat(2)'
  </code></pre>
  
  <p>New to python and programming so any help would be apprecitated. This is also a general example...my real script will have a lot more functions.</p>
  
  <p>Thank you</p>