netarch/bitarray.py

11 lines
236 B
Python
Raw Normal View History

2007-11-12 21:11:25 -07:00
from StringIO import StringIO
class bitvector:
def __init__(self, txt):
self.txt = txt
def __getitem__(self, idx):
base, offset = divmod(idx, 8)
o = ord(self.txt[base])
return (o >> offset) & 1