In article <[email protected]>, "andrew cooke" <[email protected]> wrote:
> David C. Ullrich wrote: > > In article <[email protected]>, > > Scott David Daniels <[email protected]> wrote: [...] > >> > >> class Vector(list): > >> def __add__(self, other): > >> return type(self)(x + y for x, y in zip(self, other)) > > > > Question: I would have thought it would be > > > > return type(self)([x + y for x, y in zip(self, other)]) > > > > What's this thing that looks like a list comprehension but isn't? > > it's a generator expression. > http://docs.python.org/3.0/reference/expressions.html#index-3735 Ah, thanks. I see "dict comprehensions" there too - keen. Sometime I gotta get around to actually learning this 2.x stuff. Thought I had an idea how 1.x worked... > andrew -- David C. Ullrich -- http://mail.python.org/mailman/listinfo/python-list
