title: Python - How to parse argv on the command line using stdin/stdout?
body: <p>I'm new to programming. I looked at tutorials for this, but I'm just getting more confused. But what I'm trying to do is use stdin and stdout to take in data, pass it through arguments and print out output results. </p>
  
  <p>So basically,on the command line, the user will input the  and an argument. </p>
  
  <p>The arguments are:</p>
  
  <pre><code>i = sys.argv [1]
  
  f = sys.argv [2]
  
  w = sys.argv [3]
  </code></pre>
  
  <p>Then using if/else the program will execute some stuff based on which argument chosen above.</p>
  
  <p>i.e: On the command line the user will enter the script name and <code>f</code> (for <code>sys.argv[2:2]</code>)</p>
  
  <pre><code>$ test.py f
  </code></pre>
  
  <p>.</p>
  
  <pre><code>if sys.argv == i:
       #execute some stuff
  
  elif sys.argv == f:
        #execute some stuff
  
  else: 
       sys.argv == w
       #execute some stuff
  </code></pre>
  
  <p>With stdin/stdout how can I create this switch where the program executes one piece of the code based on which <code>argv</code> is chosen? Any input will be greatly appreciated. </p>