title: Looping over specific bytes in binary file
body: <p>I want to find the points in a binary file that have specific bytes. For example say I want to check all instances in my file that start with the two bytes: </p>
  
  <p>AB C3</p>
  
  <p>And end with the two bytes: </p>
  
  <p>AB C4</p>
  
  <p>Right now I am doing </p>
  
  <pre><code>    while True:
          byte = file.read(1)
           if not byte:
             break
           if ord(byte) == 171:
  </code></pre>
  
  <p>But then how will I continue the loop so that once I find the first AB- I will see that consecutively the next byte is C3. And then once I find C3 how will I read in bytes to loop through until the sequence AB C4 (if it exists) without messing up my overall loop structure. </p>
  
  <p>I am running into difficulty because I am not sure how to approach python's read and seek functions. Should I keep a pointer to seek back to when I find the sequences? Is there a simple way to do what I am trying to do in python that I am just unaware of? </p>
  
  <p>Thanks. </p>