Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Kent Johnson
On Sun, Aug 30, 2009 at 11:59 AM, Skipper Seabold wrote: > Hello all, > > Fair warning, I didn't know what a bitfield was a few hours ago. > > I am working with a program via the dbus module and I am wondering if > there is built-in support to deal with bitfields in Python.  I query > my applicatio

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Skipper Seabold
On Sun, Aug 30, 2009 at 1:58 PM, Alan Gauld wrote: > > "Skipper Seabold" 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. >> N

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Alan Gauld
"Skipper Seabold" 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

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Luke Paireepinart
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.I.E. >>> bitfield = 119 >>> seek = bitfield & CAN_SEEK >>> seek 16 >>> if seek: print "Hello" Hello >>> if

Re: [Tutor] Dealing with bitfields in Python

2009-08-30 Thread Skipper Seabold
On Sun, Aug 30, 2009 at 1:25 PM, Luke Paireepinart 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. > I.E. bitfield = 119 seek = bitfi

[Tutor] Dealing with bitfields in Python

2009-08-30 Thread Skipper Seabold
Hello all, Fair warning, I didn't know what a bitfield was a few hours ago. I am working with a program via the dbus module and I am wondering if there is built-in support to deal with bitfields in Python. I query my application and it returns a bitfield 119. The bitfield "key" is NONE