title: call command line from python class
body: <p>I have a class which take a file, do some processes, and output a tab delimited file.
  I need to sort this output file, the easiest way is command line: sort -k1,1 -k2,2n -k3,3n</p>
  
  <p>However, I would like to implement this into a python class.</p>
  
  <p>I tried:</p>
  
  <pre><code>from subprocess import call
  
  # classA take input file, do something, output a file, named 'tmp_output'
  class ClassA(object):
      def __init__(self,tmp_input,tmp_output):
          self.tmp_input = tmp_input
          self.tmp_output = tmp_output
          self.dosomething(tmp_input)
  
      def dosomething(self,tmp_input):
          outputfile = open(self.tmp_output,'w')
          #dosomething
          # something = ...
          outputfile.write(something)
  
  # call this class to do something
  a=ClassA('tmp_input','tmp_output') # this output a file called tmp_output
  
  # Another class to sort tmp_output
  class Sort(object):
      def __init__(self,tmp_output,output):
          self.tmp_output = tmp_output
          self.output = output
  
      def sort(self):
          call('sort -k1,1 -k2,2n -k3,3n self.tmp_output &gt; self.output') # THIS STEP DOES NOT WORK
  </code></pre>
  
  <p><strong>My question</strong> is how to call sort -k1,1 -k2,2n -k3,3n, as the input and output are taken from class variables.</p>