How to test whether bit is set within a flag with Python ?

robert somerville rbrt.somerville at gmail.com
Wed May 12 14:10:20 EDT 2010


I am trying to determine how to test whether variors bits are set within a
byte (or larger flag) , the python 'and' and 'or' do not seem to be doing
what i want .. does anybody have some sample code showing how to do it ??

e.g. (in "C")

unsigned char a = 6;

is 3rd bit set ??

a & 4 =,  true in this case ....

thanks
Robert Somerville
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100512/60dd205f/attachment.html>


More information about the Python-list mailing list