On 21/11/2011 16:52, Matthew Lenz wrote:
Ahh. Ok. So how would I go about doing that with python? I think in perl (sorry for the naughty word) I could use the tr// (translate) but is there a quick way to do so with python? Is it going to be necessary to convert commands I SEND to the device or only convert what I receive?
Python strings have a .translate method: # Example in Python 2 import string # From top bit set... from_chars = "".join(chr(c | 0x80) for c in range(0x7F)) # ...to top bit clear. to_chars = "".join(chr(c) for c in range(0x7F)) # Build the translation table. force_clear = string.maketrans(from_chars, to_chars) s = "\x41\xC1" print s print s.translate(force_clear) -- http://mail.python.org/mailman/listinfo/python-list