Set parity of a string

snacktime snacktime at gmail.com
Sun Jan 23 21:32:10 EST 2005


On Sun, 23 Jan 2005 21:00:25 -0500, Peter Hansen <peter at engcorp.com> wrote:
> Peter Hansen wrote:
> > snacktime wrote:
> >> Is there a module that sets the parity of a string?
> >
> > As to the specific question: a module is not really required.
> 
> But here's one for you anyway.  It raises an exception if any
> input character is non-ASCII, otherwise when you call set_parity()
> with a string and a parity parameter of 'even', 'mark', 'none',
> 'odd', or 'space', it returns a string of the same length with
> the high (parity) bits set appropriately.

Thanks for the code example, I'm not quite up to speed on python
enough  to make this a trivial exercise as of yet.

Chris



More information about the Python-list mailing list