"Paul Rubin" <http://[EMAIL PROTECTED]> wrote:
> "Hendrik van Rooyen" <[EMAIL PROTECTED]> writes:
> > s = 'some string that needs a bcc appended'
> > ar = array.array('B',s)
> > bcc = 0
> > for x in ar[:]:
> > bcc ^= x
> > ar.append(bcc)
> > s=ar.tostring()
>
> Untested:
>
> import operator
> s = 'some string that needs a bcc appended'
> ar = array.array('B',s)
> s += chr(reduce(operator.xor, ar))
>
Yikes! - someday soon I am going to read the docs on
what reduce does...
Won't this be slow because of the double function call on each char?
- Hendrik
--
http://mail.python.org/mailman/listinfo/python-list