Re: adding vectors

2005-12-19 Thread Terry Hancock
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 t

Re: adding vectors

2005-12-19 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes: > >>> map(operator.add, (1, "abc", 0.3), (2, "def", 10.2)) > [3, 'abcdef', 10.5] > > Not having to do the zip is win. operator.add is a lose. I'm not sure > either is what I'd call elegant. Yeah, I didn't bother checking whether you could pass dyadic functio

Re: adding vectors

2005-12-19 Thread Alex Martelli
Andy Leszczynski <[EMAIL PROTECTED]> wrote: > Hi, > > Short question: why (1,"abc",0.3)+(2,"def",10.2) != (3,"abcdef",10.5)? Because '+' applied to sequences means to concatenate them -- a more frequent need than "element by element addition" (which I notice you would NOT want to apply to string

Re: adding vectors

2005-12-19 Thread Mike Meyer
Paul Rubin writes: > Andy Leszczynski <[EMAIL PROTECTED]> writes: >> 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 ... > tuple([(a+b) for a,b in zip((1,"abc",0.3),(2,"def",10.2

Re: adding vectors

2005-12-19 Thread Paul Rubin
Andy Leszczynski <[EMAIL PROTECTED]> writes: > 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 ... tuple([(a+b) for a,b in zip((1,"abc",0.3),(2,"def",10.2))]) -- http://mail.python.org/mailman/listinfo/pyt

adding vectors

2005-12-19 Thread Andy Leszczynski
Hi, 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 ... Andy -- http://mail.python.org/mailman/listinfo/python-list