title: unpack function in python
body: <p>I am trying to understand the unpack function in Python and how it uses the format string.</p>
  
  <p>I am using the format string, "I" which corresponds to unsigned int (size, 4 bytes) as an example.</p>
  
  <p>As per the documentation, the unpack function will accept a string and convert it to a list of values based on the format string.</p>
  
  <p><a href="http://docs.python.org/2/library/struct.html" rel="noreferrer">http://docs.python.org/2/library/struct.html</a></p>
  
  <p>So, I used the input value as a string, "test" and here is the output:</p>
  
  <pre><code>&gt;&gt;&gt; import struct
  &gt;&gt;&gt; input="test"
  &gt;&gt;&gt; l = struct.unpack("I", input)[0]
  &gt;&gt;&gt; print l
  1953719668
  </code></pre>
  
  <p>I am trying to understand how the output value was derived from the input.</p>
  
  <pre><code>&gt;&gt;&gt; from struct import *
  &gt;&gt;&gt; calcsize('I')
  4
  </code></pre>
  
  <p>size of 'I' is 4 bytes.
  the string, "test" has 4 characters which is 4 bytes.
  I tried converting each character to its corresponding Hex ASCII value and storing it in little endian order but it does not match the output above.</p>
  
  <p>Any help would be appreciated.</p>