What is the len
of the equivalent nested list?
len([[2,3,1,0], [2,3,1,0], [3,2,1,1]])
With the more general concept of shape
, numpy
developers choose to implement __len__
as the first dimension. Python maps len(obj)
onto obj.__len__
.
X.shape
returns a tuple, which does have a len
- which is the number of dimensions, X.ndim
. X.shape[i]
selects the ith
dimension (a straight forward application of tuple indexing).