I understand how to add new methods to a class at creation time. For Sage's 
"standard" class, this implies recompiling (part of) Sage.

I wonder if it is possible to patch a new method in an existing class. For 
example, it might be handy to give SR methods for doing what can be 
obtained by Maxima's function demoivre and exponentialize. Those methods 
would be wrappers for the (existing) functions maxima.demoivre and 
maxima.exponentialize, along the lines of 
return(maxima.demoivre(self).sage() (ditto for exponentialize).

Simple "monkey patching"  doesn't work :

def demoivre( self ):
    return(maxima.demoivre(self).sage())
def exponentialize( self ):
    return(maxima.exponentialize(self).sage())
sage.symbolic.expression.Expression.demoivre=demoivre

TypeError                                 Traceback (most recent call 
last)<ipython-input-98-2d6b16877da1> in <module>()      3 def exponentialize( 
self ):      4     return(maxima.exponentialize(self).sage())----> 5 
sage.symbolic.expression.Expression.demoivre=demoivre
TypeError: can't set attributes of built-in/extension type 
'sage.symbolic.expression.Expression'


What could work ?

--
Emmanuel Charpentier

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to