Why can't I xor strings?
Alex Martelli
aleaxit at yahoo.com
Mon Oct 11 08:05:17 EDT 2004
Bernhard Herzog <bh at intevation.de> wrote:
...
> > not str1 ^ not str2
> > not str1 != not str2
>
> These give syntax errors, actually. I wouldn't have expected that
> either, though :)
Yep, you need parentheses, as in (not str1) &c.
> > str1 != str2 and (str1+str2) == (str2+str1)
>
> Counter example:
> >>> str1 = "x"; str2 = "xx"
Yep, excellent counterexample, thanks. So let's try instead:
(str1+str2==str2!=str1) or (str2+str1==str1!=str2)
I _do_ really want something based on concatenation equaling one of the
strings iff the other's empty...
Alex
More information about the Python-list
mailing list