How to interpret 4 bytes as a 32-bit float using Python
<p>I am sort of a novice to the Python language and am having a hard time doing something I could very easily do with C++ or Java but for some reason seems so convoluted to do in Python. I have the following four bytes in an array (in big endian order): </p>

<pre><code>[0x64, 0xD8, 0x6E, 0x3F]
</code></pre>

<p>I already know beforehand what these bytes represent. They specify the following 32-bit floating-point number: <code>0.932989</code></p>

<p>What are the steps I need to perform using Python (preferably v3.2.1 and without using extra imports) to interpret those 4 bytes as that float and store that number in a variable which I can manipulate as a 32-bit floating-point value? I.e. so i can use it just as the following variable <code>myVar = 0.932989</code></p>

<p>I've tried:</p>

<pre><code>x = [0x64, 0xd8, 0x6e, 0x3f]
y = int.from_bytes(x, byteorder='little', signed=False) #interpret bytes as an unsigned little-endian integer (so far so good)
z = float(y) #attempt to cast as float reinterprets integer value rather than its byte values
</code></pre>

<p><code>y</code> has the right expected integer interpretation of those bytes, which is <code>1064228964</code>, the problem comes when casting that to a 32-bit <code>float</code>. Instead of casting the raw bytes of <code>y</code> as a float, it casts the integer representation of those bytes, so <code>z</code> contains <code>1064228964.0</code> instead of the desired value of <code>0.932989</code>. Is there maybe something equivalent to <code>int.from_bytes</code> that I can use to perform this simple task? Perhaps something like <code>float.from_bytes</code>?</p>