adding matrices of strings
William Park
parkw at better.net
Thu Oct 5 04:06:42 EDT 2000
On Wed, Oct 04, 2000 at 04:43:21PM -0500, Louis Luangkesorn wrote:
> Is there a way to add matrices of strings? In other words, if I have
> matrices A and B, whose elements are strings, can i add them so I get C
> = A + B where C[i,j] = concatonate(A[i,j], B[i,j])
Since string addition is concatenation (ie. 'a' + 'b' == 'ab'), your __add__
method should work, assuming you used '+' operator to define your addition.
>
> It does not seem like the NumPy array accepts strings, and I was
> thinking about adding lists of lists together, but all I get is the set
> of lists in A with the lists in B.
>
> the other thing I need to do is to take that matrix A, and pull a
> particular element from it (without removing that element like a
> a.pop(x) would do)
I don't get this. What's wrong with A[i][j]?
>
> Thanks
---William Park, Open Geometry Consulting
More information about the Python-list
mailing list