title: How do I access both binary and text data for email processing with Python 3?
body: <p>I am converting a Python 2 program to Python 3 and I'm not sure about the approach to take.</p>
  
  <p>The program reads in either a single email from STDIN, or file(s) are specified containing emails.  The program then parses the emails and does some processing on them.</p>
  
  <p>SO we need to work with the raw data of the email input, to store it on disk and do an MD5 hash on it.  We also need to work with the text of the email input in order to run it through the Python email parser and extract fields etc.</p>
  
  <p>With Python 3 it is unclear to me how we should be reading in the data.  I believe we need the raw binary data in order to do an md5 on it, and also to be able to write it to disk.  I understand we also need it in text form to be able to parse it with the email library.  Python 3 has made significant changes to the IO handling and text handling and I can't see the "correct" approach to read the email raw data and also use the same data in text form.</p>
  
  <p>Can anyone offer general guidance on this?</p>