Hi, A user of pytables recently asked me why it truncates the trailing spaces on strings. I have to explain him that the information is there, but the strings module of the numarray package deliberately strips off the trailing spaces when printing:
from numarray import strings a=strings.array("hello world ") print a ['hello world'] print "<%s>" % a <['hello world']> len(a[0]) 11
however:
print "<%s>" % a._data <hello world > a._byteView() array([[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 32, 32]], type=UInt8) a._itemsize 13
In the beginning I thought that this was a nice feature, but when people is using numarray.strings objects as containers (for example for Pickled objects), that can be rather confusing, and I would prefer to see all the trailing blanks. But as I am not completely sure, I just would like to discuss the pro's and con's of the current printing apprach. Cheers, -- Francesc Alted