python2.4 generator expression > python2.3 list expression
Dan Sommers
me at privacy.net
Tue Feb 22 06:40:31 EST 2005
More information about the Python-list mailing list
Tue Feb 22 06:40:31 EST 2005
- Previous message (by thread): python2.4 generator expression > python2.3 list expression
- Next message (by thread): [PyGTK] forbid focus of TreeView columns
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): python2.4 generator expression > python2.3 list expression
- Next message (by thread): [PyGTK] forbid focus of TreeView columns
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list