Spurious coercing? [was: Re: 'if foo' calls getattr?!?]
Remco Gerlich
scarblac-spamtrap at pino.selwerd.nl
Wed Jun 7 05:43:27 EDT 2000
François Pinard wrote in comp.lang.python:
> I saw many emails in which people were surprised by Python behaviour, and I
> interpret the surprise as a sign that predictability suffers. For example,
> A.__cmp__(B) will not be called for an equality comparison when A "is" B.
> Yet, given the meaning of __cmp__, this sounds absolutely correct to me.
>
> Also given the meaning of __coerce__, I would consider just equally correct
> to avoid calling A.__coerce__(B) when type(A) "is" type(B). The spontaneous
> predictable thing, here, is that __coerce__ should *not* be used when it is
> evident it should not.
But when both types are InstanceType, __coerce__ may still be needed, right?
--
Remco Gerlich, scarblac at pino.selwerd.nl
"This gubblick contains many nonsklarkish English flutzpahs, but the
overall pluggandisp can be glorked from context" (David Moser)
More information about the Python-list
mailing list