title: python itertools combination scalability
body: <p>I managed to modify sample code I found on the internet to find all possible combinations of a group of files in pairs of 2 from within a folder.  </p>
  
  <p>If I have a folder <em>test</em> which contains the following files: <em>file1, file2, file3, file4</em> and run the following code:</p>
  
  <pre><code>import os, itertools, glob
  folder = "test"
  
  files = glob.glob(folder + "/*")
  counter = 0
  for file1, file2 in itertools.combinations(files, 2):
    counter = counter + 1
    output = file1 + " and " + file2
    print output, counter
  </code></pre>
  
  <p>My output is this:</p>
  
  <pre><code>test/file1 and test/file2 1
  test/file1 and test/file3 2
  test/file1 and test/file4 3
  test/file2 and test/file3 4
  test/file2 and test/file4 5
  test/file3 and test/file4 6
  </code></pre>
  
  <p>Which is perfect for listing all of the possible groups of 2 files without repeating.  Now, since I have my <em>for</em> loop hardcoded, I'm having issues scaling this to groups of "x" files and yet keep the code simple.  IE, I would like "x" to be user-chosen such that if he chose 3, the script would show an output of:</p>
  
  <pre><code>test/file1 and test/file2 and test/file3 1
  test/file1 and test/file2 and test/file4 2
  test/file1 and test/file3 and test/file4 3
  test/file2 and test/file3 and test/file4 4
  </code></pre>
  
  <p>The whole idea isn't to actually show the output on stdout, but to use them as arguments in a subprocess call.  </p>
  
  <p>Any suggestions?</p>