The operators are defined in the standard Python module 'operator'. sage: import operator sage: (x+y)._operator is operator.add True sage: (x*y)._operator is operator.add False sage: (x*y)._operator is operator.mul True sage: (x**y)._operator is operator.mul False sage: (x**y)._operator is operator.pow True
--Mike On 10/1/07, Ondrej Certik <[EMAIL PROTECTED]> wrote: > > On 10/1/07, Mike Hansen <[EMAIL PROTECTED]> wrote: > > > > Hey Ondrej, > > > > While the correspondence is not exact, this should be enough to work: > > > > sage: e = x*y > > sage: type(e) > > <class 'sage.calculus.calculus.SymbolicArithmetic'> > > sage: e._operands > > [x, y] > > sage: e._operator > > <built-in function mul> > > sage: e = exp(y) > > sage: e._operands > > [exp, y] > > sage: type(e) > > <class 'sage.calculus.calculus.SymbolicComposition'> > > sage: var('z') > > z > > sage: f = x+y*z > > sage: f._operands > > [x, y*z] > > sage: (y*z)._operands > > [y, z] > > sage: sin(y*z)._operands > > [sin, y*z] > > > Thanks a lot. BTW, how can I test the e._operator to be add? The only > way I discovered is this: > > sage: str((x+y)._operator).find("add") != -1 > True > sage: str((x*y)._operator).find("add") != -1 > False > sage: str((x*y)._operator).find("mul") != -1 > True > sage: str((x**y)._operator).find("mul") != -1 > False > sage: str((x**y)._operator).find("pow") != -1 > True > > Which is quite fragile. :) Generally I think I know everything I need. > > Thanks, > Ondrej > > > > --~--~---------~--~----~------------~-------~--~----~ 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://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---