[Numpy-discussion] chararray behavior

Anne Archibald peridot.faceted at gmail.com
Tue Jul 8 15:30:16 EDT 2008


2008/7/8 Alan McIntyre <alan.mcintyre at gmail.com>:
> On Tue, Jul 8, 2008 at 1:29 PM, Travis E. Oliphant
> <oliphant at enthought.com> wrote:
>> Alan McIntyre wrote:
>>> 2. The behavior of __mul__ seems odd:
>>>
>> What is odd about this?
>>
>> It is patterned after
>>
>>  >>> 'a' * 3
>>  >>> 'a' * 4
>>  >>> 'a' * 5
>>
>> for regular python strings.
>
> That's what I would have expected, but for N >= 4, Q*N is the same as Q*4.

In particular, the returned type is always "string of length four",
which is very peculiar - why four?  I realize that variable-length
strings are a problem (object arrays, I guess?), as is returning
arrays of varying dtypes (strings of length N), but this definitely
violates the principle of least surprise...

Anne



More information about the NumPy-Discussion mailing list