How to convert singleton array to a scalar value in Python? : <p>Suppose I have 1x1x1x1x... array and wish to convert it to scalar?</p>

<p>How do I do it?</p>

<p><code>squeeze</code> does not help.</p>

<pre><code>import numpy as np

matrix = np.array([[1]])
s = np.squeeze(matrix)
print type(s)
print s

matrix = [[1]]
print type(s)
print s

s = 1
print type(s)
print s
</code></pre>
