Skip to main content

Input/output utirites of a bit-basis file

Project description

# bitio

Input/output utirites of bit basis file

## How to use

```py
from bitio import bit_open

f = bit_open(file_name, "r")
x = f.read() # return 1 or 0
x = f.read_bits(count) # return int

f = bit_open(file_name, "w")
f.write(bit) # write 1 if bit else 0
f.write_bits(bits, count) # write 'count bits'
f.close()
```

These are same

```py
f.write_bits(bits, count)

for i in range(count-1, -1, -1):
if bits & (1 << i):
f.write(1)
else:
f.write(0)
```

othe interface

```py
l = []
wrapper = ByteWrapper(l.append)
f = bit_wrap(wrapper, "w")
f.write_bits(0b110000101, 10)
print l # ["a"]
f.close()
print l # ["a", "@"]
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitio-0.2.tar.gz (2.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page