[Numpy-discussion] why does b[:-0] not work, and is there an elegant solution?
Sebastian Walter
sebastian.walter at gmail.com
Wed Aug 19 08:48:32 EDT 2009
I'm sure there is a better solution....:
In [1]: x = numpy.array([i for i in range(10)])
In [2]: foo = lambda n: -n if n!=0 else None
....:
In [3]: x[:foo(1)]
Out[3]: array([0, 1, 2, 3, 4, 5, 6, 7, 8])
In [4]: x[:foo(0)]
Out[4]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
On Wed, Aug 19, 2009 at 2:25 PM, Mark Bakker<markbak at gmail.com> wrote:
> Hello list,
>
> I compute the index of the last term in an array that I need and call the
> index n.
>
> I can then call the array b as
>
> b[:-n]
>
> If I need all terms in the array, the logical syntax would be:
>
> b[:-0]
>
> but that doesn't work. Any reason why that has not been implemented? Any
> elegant workaround?
>
> Thanks, Mark
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
More information about the NumPy-Discussion
mailing list