[Numpy-discussion] Response to PEP suggestions
Darren Dale
dd55 at cornell.edu
Thu Feb 17 11:39:18 CST 2005
On Thursday 17 February 2005 02:11 pm, Fernando Perez wrote:
> The danger with:
>
> if mystr[0] in ('a','b','c'): ...
>
> is that if mystr is empty, this blows up. Thanks to Python's acceptance of
> invalid indices in slices, I used
>
> if mystr[0:1] in ('a','b','c'): ...
>
Has Numeric or numarray considered allowing assignment to invalid indices? I
sometimes miss being able to do this:
a=zeros(2)
a[1:0]=1
in order to get this:
[[0,0],
[1,0]]
I guess it is not consistent with the list operations in python, but it is a
really handy shortcut for constructing arrays interactively.
Darren
More information about the Numpy-discussion
mailing list