
SINGLE_BIT_MASK =  [1 << x for x in range(7, -1, -1)]

class BitString(object):

	def __init__(self, bytes, length=None, offset=None):
		self.bytes = bytes
		self.offset = offset if offset is not None else 0
		self.length = length if length is not None else 8 * len(data) - self.offset 


	def __getitem__(self, key):
		try:
			start = key.start
			stop = key.stop
		except AttributeError:
			if key < 0 or key >= length:
				raise IndexError()
			byte_index, bit_offset = divmod(self.offset + key), 8)
			return self.bytes[byte_index] & SINGLE_BIT_MASK[bit_offset]


SINGLE_BIT_MASK =  [1 << x for x in range(7, -1, -1)]

class BitString(object):

	def __init__(self, bytes, length=None, offset=None):
		self.bytes = bytes
		self.offset = offset if offset is not None else 0
		self.length = length if length is not None else 8 * len(data) - self.offset 


	def __getitem__(self, key):
		try:
			start = key.start
			stop = key.stop
		except AttributeError:
			if key < 0 or key >= length:
				raise IndexError()
			byte_index, bit_offset = (divmod(self.offset + key), 8)
			return self.bytes[byte_index] & SINGLE_BIT_MASK[bit_offset]

Add closing paren to tuple expression
Add closing paren to tuple expression

Under Python 2.7.6, this file didn't compile for me as-is.  I still need to clone and rerun the test suite, but I thought I'd try Github's nifty "fork and edit online" feature.  Will comment again when the tests pass.