title: Python byte buffer object?
body: <p>Is there a byte buffer object in Python to which I can append values of specific types? <em>(preferably with specifiable endianess)</em></p>
  
  <p>For example:</p>
  
  <pre><code>buf.add_int(4)    # should add a 4 byte integer
  buf.add_short(10) # should add a 2 byte short
  buf.add_byte(24)  # should add a byte
  </code></pre>
  
  <p>I know that I could just use <code>struct.pack</code> but this approach just seems easier. Ideally it should be like the <code>DataOutputStream</code> and <code>DataInputStream</code> objects in <strong>Java</strong> which do this exact task.</p>