Why can't I xor strings?

Bernhard Herzog bh at intevation.de
Mon Oct 11 06:55:36 EDT 2004


aleaxit at yahoo.com (Alex Martelli) writes:

>> Grant Edwards:
>> > No, he explained exactly what he was trying to do, and it had
>> > nothing to do with encryption.  He wants to know if exactly one
>> > (1) of the strings is the empty string.
[...]

>     not str1 ^ not str2
[...]
>     not str1 != not str2

These give syntax errors, actually.  I wouldn't have expected that
either, though :)

>
>     str1 != str2 and (str1+str2) == (str2+str1)

Counter example:
>>> str1 = "x"; str2 = "xx"
>>> str1 != str2 and (str1+str2) == (str2+str1)
True


   Bernhard


-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                http://sketch.sourceforge.net/
Thuban                                  http://thuban.intevation.org/



More information about the Python-list mailing list