title: Find differences between two files in python
body: <p>I am working on a code that compares two text files in python and prints the differences between the two. I was told to use sets. Is it also possible to have a dialogue box to choose the file, instead of manually inputting file names? I am very beginner level at python, so if you could write out the code, I would really appreciate it.</p>
  
  <p>File1.txt</p>
  
  <pre><code>hamburgers
  potatoes
  avocado
  grapes
  seaweed
  </code></pre>
  
  <p>File2.txt</p>
  
  <pre><code>cheeseburgers
  potatoes
  peanuts
  grapes
  seaweed
  </code></pre>
  
  <p>so I would want the code to print 
  cheeseburgers, peanuts</p>
  
  <p>This is what I have but not sure if it's right:</p>
  
  <pre><code>old_path = 'File1.txt'
  new_path = 'File2.txt'
  
  old_lines = file(old_path).read().split('\n')
  new_lines = file(new_path).read().split('\n')
  
  old_lines_set = set(old_lines)
  new_lines_set = set(new_lines)
  
  old_added = old_lines_set - new_lines_set
  old_removed = new_line_set - old_lines_set
  
  for line in old_lines:
      if line in old_added:
          print '-' , line.strip()
      elif line in old_removed:
          print '+' , line.strip()
  
  for line in new_lines:
      if line in old added:
          print '-' , line.strip()
      elif line in old_removed:
          print '+' , line.strip ()
  </code></pre>