12.7) Information On Arrays
You can get some of the characteristics of your arrays from its attributes. Attributes are values associated with a specific type of object, in the same way that methods are functions associated with a specific type of object. The number of dimensions and the shape or size of an array are stored as attributes of the array. Here’s how you can access them:
>>> B=np.ones((2,3,4)) # create the array B >>> B.ndim # the number of dimensions 3 >>> B.shape # the shape of the array (i.e. 2 by 3 by 4) (2L, 3L, 4L) >>> B.size # the total number of elements of the array 24 >>> B.dtype # the type of data stored in the array dtype('float64')