title: Parse path as argument in python script
body: <p>This is a part of python script <code>xyz.py</code>.</p>
  
  <pre><code>#!/usr/bin/env python
  
  from openpyxl import Workbook
  import os
  wb = Workbook()
  path = "/home/Final_analysis/"
  #print(os.listdir())
  lis = os.listdir(path)
  </code></pre>
  
  <p>I wanted to use this script with different input files which are stored in different directories. For this script to run on multiple files I would have to change this part of the script every time.</p>
  
  <pre><code>path= "/home/Final_analysis/"
  </code></pre>
  
  <p>Can I parse the path as argument after python script for example</p>
  
  <pre><code>xyz.py path_to_my_file
  </code></pre>
  
  <p>in the command so that each time I don't have to change the script?</p>
  
  <p>I tried running script as above after writing <code>sys.argv[1]</code> in path </p>
  
  <pre><code>#!/usr/bin/env python
  
  from openpyxl import Workbook
  import os
  wb = Workbook()
  path = "sys.argv[1]"
  #print(os.listdir())
  lis = os.listdir(path)
  </code></pre>
  
  <p>and ran command <code>xyz.py /home/final_analysis</code> </p>
  
  <p>but it still doesn't detect the path.
  I am getting following error</p>
  
  <pre><code>Traceback (most recent call last):
    File "combine_excel.py", line 8, in &lt;module&gt;
      lis = os.listdir(path)
  OSError: [Errno 2] No such file or directory: 'sys.argv[1]'
  </code></pre>
  
  <p>I am using in python 2.7.6.</p>