[Numpy-discussion] Empty strings not empty?

Christopher Barker Chris.Barker@noaa....
Thu Dec 31 18:35:23 CST 2009


Matthew Brett wrote:
> I think the summary here is 'numpy strings are zero padded; therefore
> you may run into surprises with a string that has trailing zeros'.
> 
> I see why that is - the zero terminator is the only way for numpy
> arrays to see where the end of the string is...

almost -- it's not quite zero-terminated, you can have embedded zeros:

In [35]: np.array('aa\x00bb', dtype='S6')
Out[35]:
array('aa\x00bb',
       dtype='|S6')

-Chris





-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov


More information about the NumPy-Discussion mailing list