xor on strings

dsavitsk dsavitsk at e-coli.net
Mon Feb 11 00:04:59 EST 2002


the truncate part is the problem.  I am building VB Hex strings to send to a
VB server.  so

>>> red = hex(56)[2:4]
>>> green = hex(156)[2:4]
>>> blue = hex(12)[2:4]
>>> thestring = '&H' + blue + green + red

but here, since the blue string is only 1 character it throws the rest off.

-d

"Joshua Muskovitz" <joshm at taconic.net> wrote in message
news:3c674cbd_2 at corp.newsgroups.com...
> Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
> >>> ''.join(map(max,zip('00','AA')))
> 'AA'
> >>> ''.join(map(max,zip('00','A')))
> 'A'
> >>> ''.join(map(max,zip('00','')))
> ''
>
> Damn, I thought I had it.  :-)  Is there an variant of zip which doesn't
> truncate?  BTW, this does work, provided that the input strings are the
same
> length, and even allows for more than two strings!
>
> >>> s = ['abte','scrt','sdfw','cxvs']
> >>> ''.join(map(max,zip(*s)))
> 'sxvw'
>
> --
> # Joshua Muskovitz
> # joshm at taconic.net
> def lyyrs(sig): return '-'.join(sig.split()+["ly y'rs"])
> lyyrs('Hire me!  I need the work!')
>
>
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----





More information about the Python-list mailing list