On Thu, 26 Mar 2009 12:42:01 -0400 (CLT)
"andrew cooke" <and...@acooke.org> wrote:

> that's cute, but if you show them 2.6 or 3 it's even cuter:
> 
> >>> from operator import add
> >>> class Vector(list):
> ...   def __add__(self, other):
> ...     return map(add, self, other)
> ...
> >>> x = Vector([1,2])
> >>> x+x
> [2, 4]

Works for me in 2.5.4 (Linux) :-)

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

Reply via email to