Why can't I xor strings?

Grant Edwards grante at visi.com
Mon Oct 11 17:19:37 CEST 2004


On 2004-10-11, Alex Martelli <aleaxit at yahoo.com> wrote:

>> 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,

I guess I was assuming Python was doing the equivalent of
bool(x) when x was used as an operand of a logical operator.
That's coercion to me.

> 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>.

I guess I'm misusing the term coercion (at least in a Python
context).  To _me_ operands of logical operators are being
coerced to boolean.

-- 
Grant Edwards                   grante             Yow!  I'm gliding over a
                                  at               NUCLEAR WASTE DUMP near
                               visi.com            ATLANTA, Georgia!!



More information about the Python-list mailing list