[Numpy-discussion] what is data attribute of numpy.str_ ?

josef.pktd at gmail.com josef.pktd at gmail.com
Tue Jul 23 04:46:44 EDT 2013

python 3.3

I have a bug because we have a check for a .data attribute, that is
not supposed to be available for a string.

(Pdb) dir(data)
['T', '__abs__', '__add__', '__and__', '__array__',
'__array_interface__', '__array_priority__', '__array_struct__',
'__array_wrap__', '__bool__', '__class__', '__contains__', '__copy__',
'__deepcopy__', '__delattr__', '__dir__', '__divmod__', '__doc__',
'__eq__', '__float__', '__floordiv__', '__format__', '__ge__',
'__getattribute__', '__getitem__', '__getnewargs__', '__gt__',
'__hash__', '__init__', '__int__', '__invert__', '__iter__', '__le__',
'__len__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__',
'__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__',
'__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__',
'__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__',
'__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__',
'__rtruediv__', '__rxor__', '__setattr__', '__setstate__',
'__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__',
'__xor__', 'all', 'any', 'argmax', 'argmin', 'argsort', 'astype',
'base', 'byteswap', 'capitalize', 'casefold', 'center', 'choose',
'clip', 'compress', 'conj', 'conjugate', 'copy', 'count', 'cumprod',
'cumsum', 'data', 'diagonal', 'dtype', 'dump', 'dumps', 'encode',
'endswith', 'expandtabs', 'fill', 'find', 'flags', 'flat', 'flatten',
'format', 'format_map', 'getfield', 'imag', 'index', 'isalnum',
'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower',
'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'item',
'itemset', 'itemsize', 'join', 'ljust', 'lower', 'lstrip',
'maketrans', 'max', 'mean', 'min', 'nbytes', 'ndim', 'newbyteorder',
'nonzero', 'partition', 'prod', 'ptp', 'put', 'ravel', 'real',
'repeat', 'replace', 'reshape', 'resize', 'rfind', 'rindex', 'rjust',
'round', 'rpartition', 'rsplit', 'rstrip', 'searchsorted', 'setfield',
'setflags', 'shape', 'size', 'sort', 'split', 'splitlines', 'squeeze',
'startswith', 'std', 'strides', 'strip', 'sum', 'swapaxes',
'swapcase', 'take', 'title', 'tofile', 'tolist', 'tostring', 'trace',
'translate', 'transpose', 'upper', 'var', 'view', 'zfill']
(Pdb) data
(Pdb) type(data)
<class 'numpy.str_'>
(Pdb) data.data
*** TypeError: memoryview: numpy.str_ object does not have the buffer interface


More information about the NumPy-Discussion mailing list