On Oct 9, 2008, at 4:14 AM, Martin Albrecht wrote:

>
> While looking into #4250 I came across this code in Integer.__pow__
>
>         if not PY_TYPE_CHECK(self, Integer):
>             if isinstance(self, str):
>                 return self * n
>             else:
>                 return self ** int(n)
>
> I wonder what motivated the check whether self is an Integer?

self can be either the first or second argument of an arithmetic  
operator for an extension class (this is just how Python works).  
Usually we don't have to worry about that in Sage as the coercion  
model makes sure that both are of the same type (or at least same  
parent) before user code gets called.

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to