Manipulating bitsets in struct

2008-07-09 Thread Allen
I'm using Python to do some simple network programming, and found the struct module very useful for such things, but is there a way to easily manipulate bitsets such as a 16 bit word being split into 4 parts like 2 bits, 1 bit, 4 bits, and 9 bits? Perhaps something like:

Re: Manipulating bitsets in struct

2008-07-09 Thread Larry Bates
Allen wrote: I'm using Python to do some simple network programming, and found the struct module very useful for such things, but is there a way to easily manipulate bitsets such as a 16 bit word being split into 4 parts like 2 bits, 1 bit, 4 bits, and 9 bits? Perhaps something like:

Re: Manipulating bitsets in struct

2008-07-09 Thread Marc 'BlackJack' Rintsch
On Wed, 09 Jul 2008 20:04:24 -0400, Allen wrote: I'm using Python to do some simple network programming, and found the struct module very useful for such things, but is there a way to easily manipulate bitsets such as a 16 bit word being split into 4 parts like 2 bits, 1 bit, 4 bits, and 9