[Numpy-discussion] Is a string a scalar?
Robert Kern
robert.kern at gmail.com
Wed May 7 16:37:37 EDT 2008
On Wed, May 7, 2008 at 3:24 PM, Keith Goodman <kwgoodman at gmail.com> wrote:
> >> np.isscalar('string')
> True
<shrug> Either option would cause someone to complain. It's not a
cut-and-dry issue. However, since strings can be atomic elements
through the various '|S<N>' dtypes, and we already have rules to
special-case strings as atomic, "numpy.isscalar('string') == False"
would be more inconsistent.
In [1]: from numpy import *
In [2]: array(['one', 'two'])
Out[2]:
array(['one', 'two'],
dtype='|S3')
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list