adding vectors

Paul Rubin http
Mon Dec 19 23:36:36 EST 2005


Mike Meyer <mwm at mired.org> 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 functions
to map.  Given that you can, I see nothing wrong with lambda x,y: x+y
instead of operator.add, but that's just me.



More information about the Python-list mailing list