title: Python - feed an object with a list
body: <p>So I have the following code, which merges two text files (strings) into a list. This list should then feed an object.</p>
  
  <blockquote>
    <p>cat file1.txt</p>
  </blockquote>
  
  <pre><code>['2.02', '-3.88', '15.25']
  ['4.40', '-2.36', '14.97']
  ['5.44', '0.34', '7.34']
  ['5.76', '0.41', '7.60']
  ['5.35', '0.19', '13.95']
  </code></pre>
  
  <blockquote>
    <p>cat file2.txt</p>
  </blockquote>
  
  <pre><code>['P1']
  ['P2']
  ['P3']
  ['P4']
  ['P5']
  </code></pre>
  
  <blockquote>
    <p>Code</p>
  </blockquote>
  
  <pre><code>from ast import literal_eval
  
  #combine both files and return a list
  def combiner(infile1, infile2):
      with open(infile1) as f1, open(infile2) as f2:
          f1_lists = (literal_eval(line) for line in f1)
          f2_lists = (literal_eval(line) for line in f2)
          for l1, l2 in zip(f1_lists, f2_lists):
              l3 = l1 + l2
              return l3
  
  
  class Compass:
  
  def __init__(self, coordx, coordy, coordz, positivity):
          self.coordX = coordx
          self.coordY = coordy
          self.coordZ = coordz
          self.posit = posit
  
  def main():
      file1 = "file1.txt"
      file2 = "file2.txt"
      args = combiner(file1, file2)
      c = Compass(*args)
      print c.coordX + ' ' + c.coordY + ' ' + c.coordZ + ' ' + c.posit
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <blockquote>
    <p>output</p>
  </blockquote>
  
  <pre><code>2.02 - 3.88 15.25 P1
  </code></pre>
  
  <p>It outputs just the first list of course. How would you do to keep feeding until the list is over? 
  Maybe using the lines from the file1.txt?</p>