Why can't I xor strings?
Steven Bethard
steven.bethard at gmail.com
Fri Oct 8 21:03:03 EDT 2004
Grant Edwards <grante <at> visi.com> writes:
> No, he wants to do an exclusive or of the boolean values of the
> strings.
I'm guessing the OP has already guessed this solution from the variety already
provided, but the direct translation of this statement would be:
bool(x) ^ bool(y)
for example:
>>> bool("") ^ bool("a")
True
>>> bool("") ^ bool("")
False
>>> bool("a") ^ bool("a")
False
>>> bool("a") ^ bool("")
True
Steve
More information about the Python-list
mailing list