[EMAIL PROTECTED] (Flavio codeco coelho) writes: > I'll put your Ideas to the test ASAP, meanwhile, could you point me to > references to these bit operations in Python? I am new to this stuff, > and might need to do more of this to support other hardware... > > I havent been able to find anything about this on the python > documentation..
ord(ch) turns a character into an integer, i.e. ord('a') = 97, etc. You can use the << (left shift), >> (right shift), | (logical or), and & (logical and) operations just like in C. So for your diagram |-------------bits(1-8)-----------| Byte1: x x x n1 n2 n3 n4 n5 Byte2: x n6 n7 n8 n9 n10 n11 n12 assuming n1 is the high order bit, you'd just say value = ((ord(byte1) & 0x1f) << 7) | (ord(byte2) & 0x3f) or something like that. -- http://mail.python.org/mailman/listinfo/python-list