On 6/7/2010 6:20 AM, Ulrich Eckhardt wrote:
Ulrich Eckhardt wrote:
    data = f.read()
    for byte in data:
        for i in range(8):
            bit = 2**i&  byte
            ...

Correction: Of course you have to use ord() to get from the single-element
string ("byte" above) to its integral value first.

In Py3 (OP did not specify), a binary file is read as bytes, which is a sequence of ints, and one would have to not use ord() ;=)

tjr



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to