[Numpy-discussion] Empty strings not empty?
Matthew Brett
matthew.brett@gmail....
Tue Dec 29 19:20:12 CST 2009
Hi,
> x = "¥00"
> arr = np.array([x])
> lst = [x]
>
> arr[0] == x # False
> arr[0] == "" # True
>
> lst[0] == x # True
> lst[0] == "" # False
Ah - thanks - got it.
>> It looks to me as though the
>> buffer contents of [''] is a length 1 string with a 0 byte, and an
>> array.size of 1 - is that also what you think? I guess I think that
>> it should be a length 0 string, with a array.size of 0
>
> Array size of 0 would be very weird: it means it would have no items,
> whereas it actually has one item (which itself has a size 0).
Is this a string-specific thing? I mean, you can have size 0 1d
numeric arrays. Sorry if I'm being slow, it's late here.
In [70]: np.array([[]]).shape
Out[70]: (1, 0)
In [71]: np.array([[]]).size
Out[71]: 0
Cheers,
Matthew
More information about the NumPy-Discussion
mailing list