<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6249.1">
<TITLE>Python and Coercion</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">Dear developers:</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">__coerce__ does not seem to work in new-style classes, e.g.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">class foo:</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; def __int__(self): return 1</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; def __coerce__(self,other):&nbsp; return int(self), int(other)</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">x = foo()</FONT>

<BR><FONT SIZE=2 FACE="Arial">print 1+x</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">works fine, but if foo is derived from object, it fails with:</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">TypeError: unsupported operand type(s) for +: 'int' and 'foo'</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">After finding this difference, I could not figure out if this was</FONT>

<BR><FONT SIZE=2 FACE="Arial">an interpreter error or a documentation error.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial"><A HREF="http://www.python.org/doc/current/ref/coercion-rules.html">http://www.python.org/doc/current/ref/coercion-rules.html</A></FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">states that: &quot;In Python 3.0, coercion will not be supported.&quot;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">so I thought maybe this was the first round of removing this</FONT>

<BR><FONT SIZE=2 FACE="Arial">support.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">I googled around for awhile trying to find supporting documentation for</FONT>

<BR><FONT SIZE=2 FACE="Arial">this -- it appears it might have to do with PEP 228, but I'm not really</FONT>

<BR><FONT SIZE=2 FACE="Arial">sure, so I was hoping someone could point me at a reference point for</FONT>

<BR><FONT SIZE=2 FACE="Arial">this statement.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Regards,</FONT>

<BR><FONT SIZE=2 FACE="Arial">Pat Maupin</FONT>
</P>
<BR>

<p>This email and any attachments thereto may contain private, confidential, 
and privileged material for the sole use of the intended recipient. Any 
review, copying, or distribution of this email (or any attachments thereto) 
by others is strictly prohibited. If you are not the intended recipient, 
please contact the sender immediately and permanently delete the original 
and any copies of this email and any attachments thereto.

</BODY>
</HTML>