python2.4 generator expression > python2.3 list expression

Dan Sommers me at privacy.net
Tue Feb 22 06:40:31 EST 2005


On 22 Feb 2005 09:14:50 GMT,
Duncan Booth <duncan.booth at invalid.invalid> wrote:

> Here's yet another way to achieve the same results. This version doesn't 
> iterate over any bits at all:

>>>> import operator
>>>> parity = [ False ]
>>>> for i in range(7):
>         parity += map(operator.not_, parity)

Very clever!  :-)

Picking a nit, that version iterates over *two* sets of bits.  The "for"
loop over each possible bit in the input values.  The "map" function
over the parity bits accumulated up to that point.  And the "+="
operator over those same bits again.  Make that *three* sets of bits.

I stand humbled.

Regards,
Dan

-- 
Dan Sommers
<http://www.tombstonezero.net/dan/>
μ₀ × ε₀ × c² = 1



More information about the Python-list mailing list