title: Binary file IO in python, where to start?
body: <p>As a self-taught python hobbyist, how would I go about learning to import and export binary files using standard formats?</p>
  
  <p>I'd like to implement a script that takes ePub ebooks (XHTML + CSS in a zip) and converts it to a mobipocket (Palmdoc) format in order to allow the Amazon Kindle to read it (as part of a larger project that I'm working on).  </p>
  
  <p>There is already an awesome open-source project for managing ebook libraries : <a href="http://calibre.kovidgoyal.net/" rel="noreferrer">Calibre</a>.  I wanted to try implementing this on my own as a learning/self-teaching exercise.  I started looking at their <a href="http://bazaar.launchpad.net/~kovid/calibre/trunk/files/head%3A/src/calibre/ebooks/mobi/" rel="noreferrer">python source code</a> and realized that I have no idea what is going on.  Of course, the big danger in being self-taught at anything is not knowing what you don't know.  </p>
  
  <p>In this case, I know that I don't know much about these binary files and how to work with them in python code (<a href="http://www.python.org/doc/2.6/library/struct.html#module-struct" rel="noreferrer">struct</a>?).  But I think I'm probably missing a lot of knowledge about binary files in general and I'd like some help understanding how to work with them.  <a href="http://wiki.mobileread.com/wiki/MOBI" rel="noreferrer">Here is a detailed overview</a> of the mobi/palmdoc headers.  Thanks!</p>
  
  <p>Edit: No question, good point!  Do you have any tips on how to gain a basic knowledge of working with binary files?  Python-specific would be helpful but other approaches could also be useful.</p>
  
  <p>TOM:Edited as question, added intro / better title</p>