title: passing variable to loop as string in python
body: <p>I have a python script that will take each file in a directory, iterate through the contents of the file and create an output file for each input file. This output file may have duplicate entries and if it does I would like to take only the unique values similar to the UNIX command</p>
  
  <pre><code>uniq -u input.file &gt; output.file
  </code></pre>
  
  <p>Although I could use shell scripts to do this I would like to include a line of python that will take only unique values. I know i can do this:</p>
  
  <pre><code>import os
  os.system("uniq -u input.file &gt; output.file")
  </code></pre>
  
  <p>However when I attempt to put this in a loop so that it will make unique all of the files I just made:</p>
  
  <pre><code>for curfile in fs:
      if curfile[-3:]=='out':
          os.system("uniq -u %s &gt; %s") % (str(curfile), str(curfile[:-4] + ".uniq")
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>unsupported operand type(s) for %: 'int' and 'tuple'
  </code></pre>
  
  <p>I have tried a few syntaxes to try to get the variables recognized but can't find a similar enough example on the web. Any suggestions would be greatly appreciated.</p>