title: Struct length of long depending on byte order?
body: <p>I want to use <code>struct.unpack()</code> to get a long value from a byte string in Python 2.7, but I found some strange behaviour and I would like to know if this is a bug or not, and also, what I can do to get around it.</p>
  
  <p>What happens is the following:</p>
  
  <pre><code>import struct
  &gt;&gt;&gt; struct.unpack("L","")
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  struct.error: unpack requires a string argument of length 8
  </code></pre>
  
  <p>This is the expected behaviour. It wants an 8-byte string to extract the 8-byte long value.</p>
  
  <p>Now I change the byte order to network byte order and I get the following:</p>
  
  <pre><code>&gt;&gt;&gt; struct.unpack("!L","")
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  struct.error: unpack requires a string argument of length 4
  </code></pre>
  
  <p>Suddenly it only wants 4 bytes for the 8-byte long value.</p>
  
  <p>What is up with that, and what can I do to get around this?</p>