Diez B. Roggisch deets at
Mon May 1 23:30:47 CEST 2006

Klaas schrieb:
> Diez wrote:
>> First of all: it's considered bad style to use range if all you want is a
>> enumeration of indices, as it will actually create a list of the size you
>> specified. Use xrange in such cases.
>> But maybe nicer is zip:
>> c = [av * bv for av, bv in zip(a, b)]
> By your logic, shouldn't it also be "bad style" to create an
> unnecessary list with zip instead of using izip?

Yep. I always forget about the itertools. And then of course we'd go for 
an generator expression, won't we?


More information about the Python-list mailing list