[Numpy-discussion] why does b[:-0] not work, and is there an elegant solution?

Citi, Luca lciti@essex.ac...
Wed Aug 19 07:47:04 CDT 2009

The problem is that n is integer and integer do not have different representations for 0 and -0 (while floats do).
Therefore it is impossible to disambiguate the following two case scenarios:

>> b[:n] # take the first n

>> b[:-n] # take all but the last n

when n ==0.

One possible solution (you decide whether it is elegant :-D ):
>> b[:len(b)-n]

More information about the NumPy-Discussion mailing list