title: How can I detect if a file is binary (non-text) in Python?
body: <p>How can I tell if a file is binary (non-text) in Python?</p>
  <p>I am searching through a large set of files in Python, and keep getting matches in binary files. This makes the output look incredibly messy.</p>
  <p>I know I could use <code>grep -I</code>, but I am doing more with the data than what grep allows for.</p>
  <p>In the past, I would have just searched for characters greater than <code>0x7f</code>, but <code>utf8</code> and the like, make that impossible on modern systems. Ideally, the solution would be fast.</p>