Why Python does *SLICING* the way it does??

Paul Rubin http
Thu Apr 21 22:17:24 EDT 2005


beliavsky at aol.com writes:
> > Suppose you could.  Then what should
> > ([3, 1, 4] indexbase 0) + ([1, 5, 9] indexbase 4)
> > equal?

> If + means add, the result would be ([4,6,13] indexbase 0) .

That's counterintuitive.  I'd expect c = a + b to result in c[i] =
a[i]+b[i] for all elements.  So, for example,
   ([0,1,2,3,4] indexbase 0) + ([2,3] indexbase 2)
should result in ([0,1,4,6,4] indexbase 0)
and ([3, 1, 4] indexbase 0) + ([1, 5, 9] indexbase 4)
should either result in ([3,1,4,0,1,5,9] indexbase 0) or
else raise an exception.



More information about the Python-list mailing list