Binary Input: read how?

Michael Morrison borlak at home.com
Mon Jun 19 18:48:46 EDT 2000


Here's the basic problem: I can read a binary file using open(...,'rb') but
when I assign it to a object (b = file.read()) it stores it as an escape
character or \300 - whatever range.

I want to test this byte of binary data by comparing it's bits.  b[0] & 1 ..
b[0] & 2
for x in range(30):
    if b[0] & 2**x:
        print 1,
    else
        print 0,

This doesn't work.  Tried all sorts of things.... Can't get it to work :(

What am I missing here?

thanks





More information about the Python-list mailing list