Why can't I xor strings?
Alex Martelli
aleaxit at yahoo.com
Mon Oct 11 10:35:17 EDT 2004
Grant Edwards <grante at visi.com> wrote:
> On 2004-10-11, Alex Martelli <aleaxit at yahoo.com> wrote:
> > Grant Edwards <grante at visi.com> wrote:
> > ...
> >> Probably so, but that doesn't support the arguement that
> >> there's something wrong with a logical xor argument coercing
> >> it's operands to boolean values unless one also argues that
> >> the logical "and", "or" and "not" operators should also not
> >> coerce their operands to booleans.
> >
> > One of the greatest sources of usefulness for 'and' and 'or' is exactly
> > that these operators _don't_ coerce their operands
>
> Surely they must coerce the operands for the "test" part if not
> for the "return" part.
We may have different conceptions about the meaning of the word
"coerce", perhaps...? For example, Python may be doing len(x) when I
use x in a boolean context, but I sure don't see computing len(x) as
"coercing" anything. To me, Coercion, in Python, is what's documented
at <http://docs.python.org/ref/coercion-rules.html> and is quite a
different concept from Truth Value Testing, which is documented at
<http://docs.python.org/lib/truth.html>.
Alex
More information about the Python-list
mailing list