On Sat, 2005-07-23 at 20:25 -0700, Dan Bishop wrote: > Soeren Sonnenburg wrote: > > Hi all, > > > > Just having started with python, I feel that simple array operations '*' > > and '+' don't do multiplication/addition but instead extend/join an > > array: > > > > a=[1,2,3] > > >>> b=[4,5,6] > > >>> a+b > > [1, 2, 3, 4, 5, 6] > > > > instead of what I would have expected: > > [5,7,9] > > To get what you expected, use > > [x + y for (x, y) in zip(a, b)]
Thanks for this suggestion, however I am interested in understanding the design decision here... I could aswell just use numarray and get the wanted a+b by: from numarray import * a=array([1,2,3]) b=array([1,2,3]) a+b array([2, 4, 6]) Soeren -- http://mail.python.org/mailman/listinfo/python-list