title: How to create a checksum of a file in python
body: <p>I am trying to create a checksum of a file and save the checksum as a file same.  So.I monitor the the file and if the checksum changes then a do something.</p>
  
  <p>Here is the checksum</p>
  
  <p>For test.txt</p>
  
  <pre><code>contents: a
  checksum: dd18bf3a8e0a2a3e53e2661c7fb53534
  </code></pre>
  
  <p>I edit the file:</p>
  
  <pre><code>contents: aa
  checksum: dd18bf3a8e0a2a3e53e2661c7fb53534
  </code></pre>
  
  <p>here is my code: </p>
  
  <pre><code>python -c 'import hashlib;print hashlib.md5("test.txt").hexdigest()'
  </code></pre>
  
  <p>Why are the checksums the same?</p>