title: Variable number of arguments to Python script
body: <p>The command line to run my Python script is:</p>
  
  <pre><code>./parse_ms.py inputfile 3 2 2 2 
  </code></pre>
  
  <p>the arguments are an input, number 3 is the number of samples of my study each with 2 individuals. </p>
  
  <p>In the script, I indicate the arguments as follows:</p>
  
  <pre><code>inputfile = open(sys.argv[1], "r")
  nsam = int(sys.argv[2])
  nind1 = int(sys.argv[3])
  nind2 = int(sys.argv[4])
  nind3 = int(sys.argv[5])
  </code></pre>
  
  <p>However, the number of samples may vary. I can have:</p>
  
  <pre><code>./parse_ms.py input 4 6 8 2 20
  </code></pre>
  
  <p>in this case, I have 4 samples with 6, 8, 2 and 20 individuals in each.</p>
  
  <p>It seems inefficient to add another <code>sys.argv</code> everything a sample is added. Is there a way to make this more general? That is, if I write <code>nsam</code> to be equal to 5, automatically, Python excepts five numbers to follow for the individuals in each sample.</p>