[Tutor] Dealing with bitfields in Python
Skipper Seabold
jsseabold at gmail.com
Sun Aug 30 20:17:06 CEST 2009
On Sun, Aug 30, 2009 at 1:58 PM, Alan Gauld<alan.gauld at btinternet.com> wrote:
>
> "Skipper Seabold" <jsseabold at gmail.com> wrote
>
>> You can just do a binary AND with your consts and your bitfield value to
>> get
>> > each bit. The values will be the actual value (2, 4, 8, etc.) but if >
>> > you
>> > use these as a boolean it won't matter.
>> No that's perfect. It looks like I need to read up a bit more (pun
>> not intended) on the binary AND, but I think I see what it does and I
>> understand your example.
>
> You can go to the Using the OS topic in my tutorial for a quick tutoerial
> on how to extracts bits from a bitfield. There is a "sidebar" box entitled
> "Bitwise Operations and Flags" which explains the idea
>
Thanks. Your description is (of course) as clear as day.
Cheers,
Skipper
More information about the Tutor
mailing list