I've never liked that python silently ignores slices with out of range indexes. I believe this is a source of bugs (it has been for me). It goes completely counter to the python philosophy.
I vote to ban them from numpy. >>> from numpy import array >>> x = array (xrange (10)) >>> x[11] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: index out of bounds >>> x[:12] = 2 >>> x array([2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) >>> len (x) 10 Silently ignoring the error x[:12] is a bad idea, IMO. If it meant to _extend_ x to have lenght 12, at least _that_ would be reasonable (but I'm not advocating that position). I believe that out of bounds indexes should always throw IndexError. We can't change that in Python now, but maybe we can in numpy. _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
