Peter Hansen wrote: > snacktime wrote: > > Is there a module that sets the parity of a string? I have an > > application that needs to communicate with a host using even parity
> > So what I need is before sending the message, convert it from space to > > even parity. And when I get the response I need to convert that from > > even to space parity. > > By what means are the messages being delivered? I've rarely > seen parity used outside of simple RS-232-style serial communications. > Certainly not (in my experience, though it's doubtless been done) > in TCP/IP based stuff. And if it's serial, parity can be > supplied at a lower level than your code. > > As to the specific question: a module is not really required. > The parity value of a character depends only on the binary > value of that one byte, so a simple 128-byte substitution > table is all you need, plus a call to string.translate for > each string. > > -Peter And for converting back from even parity to space parity, either a 256-byte translation table, or a bit of bit bashing, like chr(ord(c) & 127), on each byte. The bank story sounds eminently plausible to me. Pick up old system where branch manager had to dial HO every evening, insert phone into acoustic coupler, etc etc and dump it on the internet ... -- http://mail.python.org/mailman/listinfo/python-list