title: How do I find the length (or dimensions, size) of a numpy matrix in python?
body: <p>For a numpy matrix in python</p>
  
  <pre><code>from numpy import matrix
  A = matrix([[1,2],[3,4]])
  </code></pre>
  
  <p>How can I find the length of a row (or column) of this matrix? Equivalently, how can I know the number of rows or columns?</p>
  
  <p>So far, the only solution I've found is:</p>
  
  <pre><code>len(A)
  len(A[:,1])
  len(A[1,:])
  </code></pre>
  
  <p>Which returns 2, 2, and 1, respectively. From this I've gathered that <code>len()</code> will return the number of rows, so I can always us the transpose, <code>len(A.T)</code>, for the number of columns. However, this feels unsatisfying and arbitrary, as when reading the line <code>len(A)</code>, it isn't immediately obvious that this should return the number of rows. It actually works differently than <code>len([1,2])</code> would for a 2D python array, as this would return 2.</p>
  
  <p>So, is there a more intuitive way to find the size of a matrix, or is this the best I have?</p>