title: Computing MD5 checksums for files in a list
body: <p>I'm working on a bit of a project in Python. I have a list of files that I want to get the md5checksums for. Then it stores the checksums in another list. Then it checks again and checks to see if they're different. I have the function for getting the checksums working but now I can't figure out how I'd add them to a list. Here is what I'm trying
  <pre><code>
  import sys, hashlib
  files = ['/home/file1', '/home/file2', '/home/file3', '/etc/passwd']
  md5s = []
  def getmd5(file, ex="", inc=""):
      m = hashlib.md5()
      try:
          fd = open(file,"rb")
      except IOError:
          print "Can't retrieve MD5sum for ", file
          pass
      content = fd.readlines()
      fd.close()
      for eachLine in content:
          if ex and eachLine.startswith(ex):
              continue
          m.update(eachLine)
      m.update(inc)
      a = m.hexdigest()
      md5s.append(a)</p>
  
  <p>for i in lists:
      getmd5(i)
      print md5s
  </pre></code>
  But when I try this I get 4 lists like so:
  <pre><code>
  ['729aebf5b3a841d3ef815e297ae2ce07']
  ['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad']
  ['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad', '0c01d98119386db13beb1bfdbae7ba2b']
  ['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad', '0c01d98119386db13beb1bfdbae7ba2b', 'b51c93a2f965b75de903d159720dd6e6']
  </pre></code></p>
  
  <p>What I'd like to do is store each hash checksum in the md5s list and then read to see if they're different.</p>