title: Most efficient way to search the last X lines of a file?
body: <p>I have a file and I don't know how big it's going to be (it could be quite large, but the size will vary greatly).  I want to search the last 10 lines or so to see if any of them match a string.  I need to do this as quickly and efficiently as possible and was wondering if there's anything better than:</p>
  
  <pre><code>s = "foo"
  last_bit = fileObj.readlines()[-10:]
  for line in last_bit:
      if line == s:
          print "FOUND"
  </code></pre>