Soeren Sonnenburg wrote: > On Sun, 2005-07-24 at 13:36 +1000, Steven D'Aprano wrote: > > On Sat, 23 Jul 2005 18:30:02 +0200, 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: > > > > * and + are not array operations, they are list operations. > > > > Lists in Python can contain anything, not just numeric values. > > That seems to be *the point*. Although list(a) + list(b) could create a > list [ a[0]+b[0], ...] and bail out if for elements '+' is not > defined... > > > Python doesn't have built-in mathematical arrays, otherwise known as > > matrices. There are modules that do that, but I haven't used them. Google > > on Numeric Python. > > Well I am aware of that but I don't understand the reasons of having > both lists (which are infect arrays) and *arrays ? *I* would rather drop > '+' and '*' to work like they do in *array ...
The number of programmers who do operations on mathematical arrays is pretty small. The number of programmers who need to do things like concatenate lists is much larger. Thus, the decision was made to use the valuable operator for the more common thing. Truth be told, I rarely use + on lists (I tend to use list.extend mostly), and if + had instead been used for element-by-element operations, I don't think it would have affected the overall quality of Python too much. But, as it's been said, it's a little late to change it now. -- CARL BANKS -- http://mail.python.org/mailman/listinfo/python-list