xor on strings
Darrell
dgallion1 at yahoo.com
Sun Feb 10 23:54:55 EST 2002
>>> from Numeric import *
>>> ar1=array(map(ord,list('0A')))
>>> ar2=array(map(ord,list('AB')))
>>> map(chr,maximum(ar1,ar2))
['A', 'B']
>>> maximum(ar1,ar2)
array([65, 66])
>>>
Ok, not a builtin and maybe not all that fast.
But I just read the Numeric tutorial.
--Darrell
dsavitsk wrote:
> maybe this isn't xor, but i would like something that will smush strings
> ... that is, something that would compare two strings position by position
> and return the higher (or lower i suppose) value piece in each position,
> i.e.
>
>>>> fun('00', 'AA')
> 'AA'
>
>>>> fun('00', 'A')
> 'A0'
>
>>>> fun('00', '')
> '00'
>
> i understand that this is easy to write, but i was looking for a builtin.
> does it exist?
>
> -d
More information about the Python-list
mailing list