[Numpy-discussion] dtype '|S0' not understood

David Warde-Farley dwf@cs.toronto....
Wed Sep 23 18:55:08 CDT 2009


It seems it's possible using e.g.

In [25]: dtype([('foo', str)])Out[25]: dtype([('foo', '|S0')])

to get yourself a zero-length string. However dtype('|S0') results in  
a TypeError: data type not understood.

I understand the stupidity of creating a 0-length string field but  
it's conceivable that it's accidental.

For example, it could lead to a situation where you've created that  
field, are missing all the data you had meant to put in it, serialize  
with np.save, and upon np.load aren't able to get _any_ of your data  
back because the dtype descriptor is considered bogus (can you guess  
why I thought of this scenario?).

It seems that either dtype(str) should do something more sensible than  
zero-length string, or it should be possible to create it with dtype('| 
S0').  Which should it be?


More information about the NumPy-Discussion mailing list