[Python-checkins] r82594 - python/branches/py3k/Demo/classes/Vec.py

Georg Brandl g.brandl at gmx.net
Mon Jul 5 23:14:49 CEST 2010


Am 05.07.2010 22:42, schrieb Alexander Belopolsky:
> On Mon, Jul 5, 2010 at 4:13 PM, georg.brandl <python-checkins at python.org> wrote:
> ..
>>         # Element-wise addition
>> -        v = list(map(lambda x, y: x+y, self, other))
>> -        return Vec().fromlist(v)
>> +        v = list(map(operator.add, self, other))
>> +        return Vec.fromlist(v)
> 
> I wonder if it would be more fitting in a 3.x demo to compute v as
> 
> v = [x + y for x, y in zip(self.v, other.v)]
> 
> or provide __iter__ and do simply
> 
> v = [x + y for x, y in zip(self, other)]
> 
> I know this suggestion may be premature before it is decided what
> stays in Demo and what does not, but +import operator has caught my
> eye.

Well, why not.  Go ahead.

Georg



More information about the Python-checkins mailing list