On Mon, 19 Dec 2005 22:06:31 -0500
Andy Leszczynski <[EMAIL PROTECTED]> wrote:
> Short question: why (1,"abc",0.3)+(2,"def",10.2) !=
> (3,"abcdef",10.5)?
> 
> How to elegantly achieve (3,"abcdef",10.5) as a result of
> addition ...

(a,b,c) is a "tuple", not a "vector".

IMHO, the "elegant" thing to do is to define a vector class
and use it. For convenience, allow a tuple initializer:

V = Vector
a = V(1,"abc",0.3) + V(2,"def",10.2)

Of course, the class "Vector" will have to define math
operators appropriately.  Note that "%" has the correct
precedence to sub for cross-product, and sort of looks like
an X if you squint hard enough ;-).

-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to