On Apr 17, 5:25 am, aaB <mecagonoisic...@gmail.com> wrote:
>
> - the "complement" thing:
> I haven't yet tried to reproduce this, but I will, and I will post back if I 
> see
> this happening again, this time with a real log of python's interactive 
> console,
> or a complete script which people can use.
>

That was happening when you incorrectly used bit as an index back into
bitpattern.
When you do that, the behavior actually changes depending on the value
of bitpattern:

a bitpattern that starts with [1, 0, ...] will yield its complement:

>>> bitpattern = [1, 0, 0, 1, 1, 0, 1]
>>> for bit in bitpattern:
        print 'bitpattern[%s] : %s' % (bit, bitpattern[bit])


bitpattern[1] : 0
bitpattern[0] : 1
bitpattern[0] : 1
bitpattern[1] : 0
bitpattern[1] : 0
bitpattern[0] : 1
bitpattern[1] : 0
>>>

while a bitpattern that starts with [0, 1, ...] will yield the
expected results:

>>> bitpattern = [0, 1, 0, 1, 1, 0, 1]
>>> for bit in bitpattern:
        print 'bitpattern[%s] : %s' % (bit, bitpattern[bit])


bitpattern[0] : 0
bitpattern[1] : 1
bitpattern[0] : 0
bitpattern[1] : 1
bitpattern[1] : 1
bitpattern[0] : 0
bitpattern[1] : 1
>>>

HTH,
Don



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to