On Oct 9, 2008, at 12:44 PM, Martin Albrecht wrote:

> On Thursday 09 October 2008, Robert Bradshaw wrote:
>> 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.
>
> Hi Robert,
>
> I understand that argument in the context of say multiplication but  
> for
> __pow__ you can't switch the parameters around (?)

Python does...

{{{
%cython
cdef class MyClass:
     def __pow__(base, exp, dummy):
         print "base", base, "exp", exp
     def __str__(self):
         return "MyClass"
///
}}}

sage: a = MyClass()
sage: a^5
base MyClass exp 5
sage: "foo"^a
base foo exp MyClass

Strange but true.

- 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